Phaser Physics 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 77
start the physics engine
Description:starts the Arcade Physics engine
Example:game.physics.startSystem(Phaser.Physics.ARCADE);

Enable an object for physics
Description:Tell Phaser to use physics on this object
Example: game.physics.enable(this.char, Phaser.Physics.ARCADE);

Set Velocity
Description:Sets the velocity of an object
Example:this.char.body.velocity.setTo(xSpeed,ySpeed);

Set Bounce
Description:sets the bounce for the when the object collides. 1 is 100% bounce. .5 is 50%
Example:this.body.bounce.set(horizontal,vertical);

Set Global Gravity
Description:Sets the default gravity for all objects
Example:game.physics.arcade.gravity.y = gravityValue;

Set object gravity
Description:Sets the gravity on an individual sprite
Example:this.char.body.gravity.y = gravityValue;

set group physics
Description:Sets up a group for physics
Example://enable body for all child sprites myGroup.enableBody = true; //set the type of physics for all child sprites myGroup.physicsBodyType = Phaser.Physics.ARCADE;

set group physics
Description:allows group children to collide with each out. Place in update function
Example:game.physics.arcade.collide(this.myGroup);