mirror of
https://github.com/wassname/phaser.git
synced 2026-08-12 12:20:38 +08:00
Lots of updates across input, rendering and grouping
This commit is contained in:
+16
-19
@@ -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
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
})();
|
||||
|
||||
Reference in New Issue
Block a user