mirror of
https://github.com/wassname/phaser.git
synced 2026-09-12 12:40:47 +08:00
Updated a lot of examples to Phaser 2.0 :)
This commit is contained in:
@@ -23,6 +23,7 @@ function create() {
|
||||
// The first parameter is how long to wait before the event fires. In this case 1 second (you could pass in 1000 as the value as well.)
|
||||
// The next two parameters are the function to call ('updateCounter') and the context under which that will happen.
|
||||
|
||||
|
||||
game.time.events.loop(Phaser.Timer.SECOND, updateCounter, this);
|
||||
|
||||
}
|
||||
@@ -31,7 +32,7 @@ function updateCounter() {
|
||||
|
||||
counter++;
|
||||
|
||||
text.content = 'Counter: ' + counter;
|
||||
text.setText('Counter: ' + counter);
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -33,9 +33,7 @@ function createBall() {
|
||||
|
||||
var ball = game.add.sprite(game.world.randomX, 0, 'ball');
|
||||
|
||||
ball.body.gravity.y = 200;
|
||||
ball.body.bounce.y = 0.5;
|
||||
ball.body.collideWorldBounds = true;
|
||||
ball.physicsEnabled = true;
|
||||
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,7 @@ function updateCounter(idx) {
|
||||
|
||||
counters[idx]++;
|
||||
|
||||
text[idx].content = 'Counter ' + idx + ' = ' + counters[idx];
|
||||
text[idx].setText('Counter ' + idx + ' = ' + counters[idx]);
|
||||
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ function removeCounter() {
|
||||
|
||||
// Just updates the text
|
||||
text[i].style.fill = '#3344aa';
|
||||
text[i].content = 'Counter ' + i + ' removed';
|
||||
text[i].setText('Counter ' + i + ' removed');
|
||||
i--;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user