Created
February 16, 2015 08:08
-
-
Save corpsefilth/efe7c4f2ea7236956155 to your computer and use it in GitHub Desktop.
Phaser Sprite reference
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
// Create a local variable | |
var someSprite = game.add.sprite(250, 170, 'someSprite'); | |
// Create a state variable | |
this.someSprite = game.add.sprite(250, 170, 'someSprite'); | |
// using predefined pos | |
this.someSprite = game.add.sprite(game.world.centerX, game.world.centerY, 'someSprite'); | |
// Set the anchor point to the top left of the sprite (default value) | |
this.someSprite.anchor.setTo(0, 0); | |
// Set the anchor point to the top right of the sprite | |
this.someSprite.anchor.setTo(1, 0); | |
// Set the anchor point to the bottom left of the sprite | |
this.someSprite.anchor.setTo(0, 1); | |
// Set the anchor point to the bottom right of the sprite | |
this.someSprite.anchor.setTo(1, 1); | |
// Change the position of the sprite | |
sprite.x = 50; | |
sprite.y = 50; | |
// Return the width and height of the sprite | |
sprite.width; | |
sprite.height; | |
// Change the transparency of the sprite. 0 = invisible, 1 = normal | |
sprite.alpha = 0.5; | |
// Change the angle of the sprite, in degrees | |
sprite.angle = 42; | |
// Remove the sprite from the game | |
sprite.kill(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment