Jump to content

Weird physics bounding box (arcade)


xompl
 Share

Recommended Posts

Not sure if this is a bug or I'm doing something wrong.

 

I've made an infinite vertical runner.

I have a bunch of blocks on screen. When a block exists the screen at the top I move it to the bottom.

Hence I only have around 50 sprites for the whole game.

 

Physics: Arcade

Version: 2.2.2

 
My problem is that when I die and restart the game, the bounding boxes of the blocks remain on screen for some reason.

 

See the example:

In the first image the player is at (x=325 y=1200). There are some sprite platforms with the bounding box rendered with debug.body(block)

 

When the player dies I go back to y=0 (image 2) the bounding boxes of the platforms remain in the same position even if the sprites are outside the screen.

 

 

This is the code that moves the blocks when they go out of the screen

for (var i = 0; i < this.blocks.length; ++i) {    var row = this.blocks[i];    if (row[0].y + 128 < player.y) { // row is outside the screen        var dif = this.blocks.length * 32;        for (var j = 0; j < row.length; ++j) {          row[j].body.y += dif;          // Select if it will be visible or not          row[j].visible = this.game.rnd.realInRange(0, 1) < 0.1;        }    }}

Any idea?

Thank you!

post-7542-0-46614100-1422200959.png

post-7542-0-77296900-1422200959.png

Link to comment
Share on other sites

Thank you for you reply spencerTL but I still see these bounding boxes.

 

I tried using body.reset(x, y), sprite.y, sprite.position.y and sprite.body.y. All have the problem I explained in the first post.

 

It make no sense that the boxes are moved to the origin (0, 0) when I move the camera and the sprite.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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