Angry B
Angry B

Reputation: 305

How to enable physics for graphic object in Phaser.js?

Here is an example of a simple Phaser.js script:

https://jsfiddle.net/u13neuza/1/

But even if graphics.body.collideWorldBounds = true; my graphic object falling down under the screen. How to make interraction between world bounds (screen border) and graphic object?

Upvotes: 0

Views: 133

Answers (1)

BdR
BdR

Reputation: 3048

The problem seems to be that the bottom of the World bounds are far below the visible screen. That's why the ball doesn't bounce back up into the screen.

I don't know what the default settings are for the worldbounds, but if you try the changes below in your example then it kind of works:

// Physics settings
game.world.setBounds(0,0,800, 300); // x, y, width, height .. just trying some values
graphics.body.bounce.y = 0.9;       // more elastic, bounce higher
graphics.body.gravity.y = 500;
// etc

Upvotes: 1

Related Questions