Lots of updates across input, rendering and grouping

This commit is contained in:
Richard Davey
2013-05-17 06:49:43 +01:00
parent a6e8436e6d
commit 55568592b5
40 changed files with 836 additions and 475 deletions
+16 -19
View File
@@ -14,29 +14,26 @@
function create() {
balls = myGame.createGroup();
myGame.input.onTap.add(tapped, this);
myGame.input.onDoubleTap.add(doubleTapped, this);
}
function doubleTapped(pointer) {
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
tempBall.velocity.y = 100 + Math.random() * 150;
tempBall.elasticity = 0.9;
tempBall.scale.setTo(4, 4);
balls.add(tempBall);
}
function tapped(pointer) {
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
tempBall.velocity.y = 100 + Math.random() * 150;
tempBall.elasticity = 0.9;
balls.add(tempBall);
function tapped(pointer, doubleTap) {
if(balls.countDead() > 0) {
var tempBall = balls.getFirstDead();
tempBall.revive();
tempBall.x = pointer.x;
tempBall.y = pointer.y;
} else {
var tempBall = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.setBoundsFromWorld(Phaser.GameObject.OUT_OF_BOUNDS_KILL);
balls.add(tempBall);
}
tempBall.velocity.y = 150;
if(doubleTap) {
tempBall.scale.setTo(4, 4);
}
}
function update() {
}
function render() {
myGame.input.renderDebugInfo(16, 16);
//myGame.input.pointer1.renderDebug(true);
//myGame.input.pointer2.renderDebug(true);
//myGame.input.pointer3.renderDebug(true);
}
}
})();
+19 -20
View File
@@ -24,28 +24,31 @@
balls = myGame.createGroup();
myGame.input.onTap.add(tapped, this);
myGame.input.onDoubleTap.add(doubleTapped, this);
}
function doubleTapped(pointer: Phaser.Pointer) {
function tapped(pointer: Phaser.Pointer, doubleTap: bool) {
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
tempBall.velocity.y = 100 + Math.random() * 150;
tempBall.elasticity = 0.9;
tempBall.scale.setTo(4, 4);
balls.add(tempBall);
if (balls.countDead() > 0)
{
var tempBall: Phaser.Sprite = <Phaser.Sprite> balls.getFirstDead();
tempBall.revive();
tempBall.x = pointer.x;
tempBall.y = pointer.y;
}
else
{
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.setBoundsFromWorld(Phaser.GameObject.OUT_OF_BOUNDS_KILL);
balls.add(tempBall);
}
}
tempBall.velocity.y = 150;
function tapped(pointer: Phaser.Pointer) {
var tempBall: Phaser.Sprite = new Phaser.Sprite(myGame, pointer.x, pointer.y, 'ball' + Math.round(Math.random() * 5));
tempBall.outOfBoundsAction = Phaser.GameObject.OUT_OF_BOUNDS_KILL;
tempBall.velocity.y = 100 + Math.random() * 150;
tempBall.elasticity = 0.9;
balls.add(tempBall);
if (doubleTap)
{
tempBall.scale.setTo(4, 4);
}
}
@@ -56,10 +59,6 @@
myGame.input.renderDebugInfo(16, 16);
//myGame.input.pointer1.renderDebug(true);
//myGame.input.pointer2.renderDebug(true);
//myGame.input.pointer3.renderDebug(true);
}
})();