Jump to content

[ASK][PASHER]bounce sprite


nduhu
 Share

Recommended Posts

how i can make image bounce in center place?

 

2hnoz60.png

 

var game = new Phaser.Game(800, 600, Phaser.CANVAS, 'phaser-example', { preload: preload, create: create, update: update, render: render });

function preload() {

game.load.image('flyer', 'assets/sprites/phaser-dude.png');
}

var image;

function create() {

game.physics.startSystem(Phaser.Physics.ARCADE);

image = game.add.sprite(0, 0, 'flyer');

game.physics.enable(image, Phaser.Physics.ARCADE);

image.body.velocity.setTo(200,200);

image.body.collideWorldBounds = true;

image.body.bounce.set(1);

}

function update () {


}

function render () {

game.debug.spriteInfo(image,32,32);

}

Link to comment
Share on other sites

If I understand you correctly, then you just need to change image.body.width, image.body.height to fit you needs.

 

(Use game.debug.body(sprite); in the render() function to see the phsyics-body).

 

Use image.body.offset.x and image.body.offset.y to adjust the position.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...