Velocity is back on track :)

This commit is contained in:
alvinsight
2014-02-21 15:53:07 +00:00
parent fb5920feec
commit 7342ce603a
4 changed files with 11 additions and 8 deletions
+3 -1
View File
@@ -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);
}
+6 -4
View File
@@ -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);
}
}
+1 -2
View File
@@ -42,7 +42,6 @@ function update() {
function render() {
game.debug.renderSpriteCorners(s, true, true);
game.debug.renderSpriteInfo(s, 20, 32);
game.debug.renderSpriteBounds(s);
}
+1 -1
View File
@@ -26,7 +26,7 @@ function create() {
function gofull() {
game.stage.scale.startFullScreen();
game.scale.startFullScreen();
}