forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed bug causing Text with empty or no given text to break. Added Wo…
…rld.createSpring.
- Loading branch information
1 parent
0584d3e
commit 8318a58
Showing
5 changed files
with
128 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
|
||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update }); | ||
|
||
function preload() { | ||
|
||
game.load.image('atari', 'assets/sprites/atari130xe.png'); | ||
game.load.image('sky', 'assets/skies/sunset.png'); | ||
|
||
} | ||
|
||
var sprite; | ||
var cursors; | ||
|
||
function create() { | ||
|
||
game.add.image(0, 0, 'sky'); | ||
|
||
// Enable p2 physics | ||
game.physics.startSystem(Phaser.Physics.P2JS); | ||
|
||
// Add a sprite | ||
sprite = game.add.sprite(200, 200, 'atari'); | ||
|
||
// Enable if for physics. This creates a default rectangular body. | ||
game.physics.p2.enable(sprite); | ||
|
||
// Create our spring | ||
var spring = game.physics.p2.createSpring(bodyA, bodyB, restLength, stiffness, damping, worldA, worldB, localA, localB); | ||
|
||
// var spring = game.physics.p2. | ||
|
||
// var spring = new p2.Spring(bodyA,bodyB, { | ||
// stiffness: k, | ||
// restLength: l, | ||
// damping : d | ||
// }); | ||
|
||
|
||
|
||
text = game.add.text(20, 20, 'move with arrow keys', { fill: '#ffffff' }); | ||
|
||
cursors = game.input.keyboard.createCursorKeys(); | ||
|
||
} | ||
|
||
function update() { | ||
|
||
// sprite.body.setZeroVelocity(); | ||
|
||
// if (cursors.left.isDown) | ||
// { | ||
// sprite.body.moveLeft(400); | ||
// } | ||
// else if (cursors.right.isDown) | ||
// { | ||
// sprite.body.moveRight(400); | ||
// } | ||
|
||
// if (cursors.up.isDown) | ||
// { | ||
// sprite.body.moveUp(400); | ||
// } | ||
// else if (cursors.down.isDown) | ||
// { | ||
// sprite.body.moveDown(400); | ||
// } | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { create: create }); | ||
|
||
function create() { | ||
|
||
var style = { font: "65px Arial", fill: "#ff0044", align: "center" }; | ||
var text = game.add.text(game.world.centerX, game.world.centerY, "x", style); | ||
|
||
text.anchor.set(0.5); | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters