Skip to content

Phaser methods with Infusion wrapper

Sparsh Paliwal edited this page Aug 23, 2016 · 1 revision

Though these methods are very obvious if you understand how the project works. But I kept these for reference so as not to again and again look at the Phaser documentation. These are surely not all the methods from the library or used in Discovery Cat, but these are the ones that are used very much in the project.

SET PROPERTIES

obj.x = <value>; obj.y = <value>;

ADD

that.add.sprite(x, y, "spriteName";) that.<name>.addChild(that.add.sprite()2);

PHYSICS

that.physics.arcade.enable(that.player); that.player.body.immovable = true; that.physics.arcade.overlap(that.sizeDoor, that.cat); // lets overlap that.physics.arcade.collide(that.ground, that.cat); //creates seperation

ASSETS

that.load.image("image_name", "image address"); that.load.spritesheet("sprite_name", "sprite_address", x-dist, y-dist); that.add.sprite(50, 50, "doorh");

INPUT CONTROLS

that.cursors = that.input.keyboard.createCursorKeys(); then simply use that.cursors.left.isDown and others. that.enter = that.input.keyboard.addKey(Phaser.Keyboard.ENTER); that.enter.isDown that.enter.onDown.add vs that.enter.onDown.addOnce

BUTTONS IN PHASER

that.add.button(x, y, "spriteSheet_name", callback, that, over, out, in);

ANIMATION

that.obj.animations.add("<anim_name>"[0, 1, 2], 10, true<loop_bool>); that.obj.play("<anim_name>");

TWEEN

that.add.tween(that.obj).to({ <values> }, <tween_time>, Phaser.Easing.Sinusoidal.InOut, true);

Clone this wiki locally