Group now extends PIXI.DisplayObjectContainer, rather than owning a _container property, which makes life a whole lot easier re: nesting.

This commit is contained in:
photonstorm
2014-02-06 02:31:36 +00:00
parent 9737710200
commit 4cfce8b4d2
89 changed files with 1176 additions and 1521 deletions
+38
View File
@@ -0,0 +1,38 @@
var game = new Phaser.Game(800, 600, Phaser.AUTO, 'phaser-example', { preload: preload, create: create });
function preload() {
game.load.image('arrow', 'assets/sprites/arrow.png');
}
var sprite;
var tween;
function create() {
sprite = game.add.sprite(32, 32, 'arrow');
sprite.anchor.setTo(0.5, 0.5);
game.input.onDown.add(moveSprite, this);
}
function moveSprite (pointer) {
if (tween && tween.isRunning)
{
tween.stop();
}
sprite.rotation = game.physics.angleToPointer(sprite, pointer);
// 300 = 300 pixels per second = the speed the sprite will move at, regardless of the distance it has to travel
var duration = (game.physics.distanceToPointer(sprite, pointer) / 300) * 1000;
tween = game.add.tween(sprite).to({ x: pointer.x, y: pointer.y }, duration, Phaser.Easing.Linear.None, true);
}