Phaser 3 Animation Snippets


Notice: Function wpdb::prepare was called incorrectly. The query argument of wpdb::prepare() must have a placeholder. Please see Debugging in WordPress for more information. (This message was added in version 3.9.0.) in /home/wcc1969/public_html/phasergames.com/wp-includes/functions.php on line 6085

Notice: Function wpdb::prepare was called incorrectly. The query does not contain the correct number of placeholders (0) for the number of arguments passed (1). Please see Debugging in WordPress for more information. (This message was added in version 4.8.3.) in /home/wcc1969/public_html/phasergames.com/wp-includes/functions.php on line 6085

Warning: Undefined variable $output in /home/wcc1969/public_html/phasergames.com/wp-content/plugins/wc_snippets/snippets.php on line 110
Sprite sheet load
Description:loads a sprite sheet
Example:this.load.spritesheet('key', 'path', { frameWidth: width, frameHeight: height});

get frame names
Description:get the frame names of a sprite sheet
Example:var textureFrames = this.textures.get('key').getFrameNames();

create an animation
Description:create an animation
Example:this.anims.create({ key: 'animationName', frames: [ { key: 'key1',:frame:frame1 }, { key: 'key2',:frame:frame2 }, ], frameRate: rate, repeat: -1 });

Play an animation
Description:play an animation
Example:sprite.play('animationName');

get frame numbers
Description:generate frame numbers from a sprite sheet. Will return an object such as: { key: 'char',frame:1 }, { key: 'char',frame:2 },
Example: var frameNames= this.anims.generateFrameNumbers('key');

animation complete event
Description:calls a function when animation is complete
Example:char.on('animationcomplete', function, scope);

Generate a key frame sequence
Description:generate a key frame sequence from a JSON file
Example:this.anims.generateFrameNames('ninja', {start: 0, end: 8, zeroPad: 3, prefix: 'Attack__', suffix: '.png'})