mirror of
https://github.com/wassname/phaser.git
synced 2026-06-27 16:10:15 +08:00
Velocity is back on track :)
This commit is contained in:
@@ -19,6 +19,8 @@ function create() {
|
||||
// and assign it to a variable
|
||||
var image = game.add.sprite(0, 0, 'einstein');
|
||||
|
||||
image.body.velocity.x=50;
|
||||
image.physicsEnabled = true;
|
||||
|
||||
image.body.moveRight(150);
|
||||
|
||||
}
|
||||
|
||||
@@ -31,6 +31,8 @@ function create() {
|
||||
|
||||
player = game.add.sprite(150, 320, 'player');
|
||||
|
||||
player.physicsEnabled = true;
|
||||
|
||||
cursors = game.input.keyboard.createCursorKeys();
|
||||
|
||||
game.camera.follow(player);
|
||||
@@ -39,15 +41,15 @@ function create() {
|
||||
|
||||
function update() {
|
||||
|
||||
player.body.velocity.setTo(0, 0);
|
||||
player.body.setZeroVelocity();
|
||||
|
||||
if (cursors.up.isDown)
|
||||
{
|
||||
player.body.velocity.y = -200;
|
||||
player.body.moveUp(200)
|
||||
}
|
||||
else if (cursors.down.isDown)
|
||||
{
|
||||
player.body.velocity.y = 200;
|
||||
player.body.moveDown(200);
|
||||
}
|
||||
|
||||
if (cursors.left.isDown)
|
||||
@@ -56,7 +58,7 @@ function update() {
|
||||
}
|
||||
else if (cursors.right.isDown)
|
||||
{
|
||||
player.body.velocity.x = 200;
|
||||
player.body.moveRight(200);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,6 @@ function update() {
|
||||
|
||||
function render() {
|
||||
|
||||
game.debug.renderSpriteCorners(s, true, true);
|
||||
game.debug.renderSpriteInfo(s, 20, 32);
|
||||
game.debug.renderSpriteBounds(s);
|
||||
|
||||
}
|
||||
|
||||
@@ -26,7 +26,7 @@ function create() {
|
||||
|
||||
function gofull() {
|
||||
|
||||
game.stage.scale.startFullScreen();
|
||||
game.scale.startFullScreen();
|
||||
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user