Phaser.CANVAS_PX_ROUND is a boolean. If 'true' the Canvas renderer will Math.floor() all coordinates before drawImage, stopping pixel interpolation. Defaults to false.

Phaser.CANVAS_CLEAR_RECT is a boolean. If 'true' (the default) it will context.clearRect() every frame. If false this is skipped (useful if you know you don't need it)
Collision now works between Sprites positioned via sprite.x/y, sprite.body.x/y or sprite.body.velocity.
If you are tweening a sprite and still want physics collision, set `sprite.body.moves = false` otherwise it will fight against the tween motion.
This commit is contained in:
photonstorm
2014-01-31 04:14:02 +00:00
parent 68b7d22e0d
commit 13a86765cb
6 changed files with 101 additions and 41 deletions
+55 -10
View File
@@ -8,7 +8,7 @@ function preload() {
game.load.image('walls_1x2', 'assets/tilemaps/tiles/walls_1x2.png');
game.load.image('tiles2', 'assets/tilemaps/tiles/tiles2.png');
// game.load.image('phaser', 'assets/sprites/shinyball.png');
game.load.image('ball', 'assets/sprites/shinyball.png');
game.load.image('phaser', 'assets/sprites/firstaid.png');
// game.load.image('phaser', 'assets/sprites/atari130xe.png');
// game.load.image('phaser', 'assets/sprites/mushroom2.png');
@@ -24,6 +24,7 @@ var layer2;
var layer3;
var sprite;
var ball;
var marker;
function create() {
@@ -34,7 +35,7 @@ console.log(' --- state create start ---');
game.step();
});
// game.stage.backgroundColor = '#124184';
game.stage.backgroundColor = '#124184';
marker = new Phaser.Line(256, 0, 256, 600);
@@ -56,7 +57,12 @@ console.log(' --- state create start ---');
// game.physics.gravity.y = 200;
sprite = game.add.sprite(100, 300, 'phaser'); // up test
sprite = game.add.sprite(100, 180, 'phaser');
sprite.body.moves = false;
ball = game.add.sprite(200, 180, 'ball');
game.add.tween(sprite).to({x: 500},5000,Phaser.Easing.Linear.None,true);
// sprite = game.add.sprite(200, 240, 'phaser'); // 3-block corner test
@@ -112,12 +118,14 @@ function update() {
layer.scrollY += 4;
}
*/
game.physics.collide(sprite, layer);
game.physics.collide(sprite, ball);
// sprite.body.velocity.y = -300;
sprite.body.velocity.x = 0;
sprite.body.velocity.y = 0;
// sprite.body.velocity.x = 0;
// sprite.body.velocity.y = 0;
// sprite.body.angularVelocity = 0;
// sprite.body.acceleration.x = 0;
@@ -157,25 +165,62 @@ function update() {
sprite.angle = sprite.angle + 1;
*/
// if (cursors.up.isDown)
// {
// sprite.body.velocity.y = -200;
// }
// else if (cursors.down.isDown)
// {
// sprite.body.velocity.y = 100;
// }
// if (cursors.left.isDown)
// {
// sprite.body.velocity.x = -200;
// }
// else if (cursors.right.isDown)
// {
// sprite.body.velocity.x = 200;
// }
// if (cursors.up.isDown)
// {
// sprite.y -= 2;
// }
// else if (cursors.down.isDown)
// {
// sprite.y += 2;
// }
// if (cursors.left.isDown)
// {
// sprite.x -= 2;
// }
// else if (cursors.right.isDown)
// {
// sprite.x += 2;
// }
if (cursors.up.isDown)
{
// console.log('cursor up');
sprite.body.velocity.y = -200;
sprite.body.y -= 2;
}
else if (cursors.down.isDown)
{
sprite.body.velocity.y = 100;
sprite.body.y += 2;
}
if (cursors.left.isDown)
{
sprite.body.velocity.x = -200;
sprite.body.x -= 2;
}
else if (cursors.right.isDown)
{
sprite.body.velocity.x = 200;
sprite.body.x += 2;
}
}
function render() {