phaserjs / phaser

Phaser is a fun, free and fast 2D game framework for making HTML5 games for desktop and mobile web browsers, supporting Canvas and WebGL rendering.
https://phaser.io
MIT License
37.12k stars 7.1k forks source link

Phaser.Physics.ARCADE Bug when moving the camera #947

Closed casensiom closed 10 years ago

casensiom commented 10 years ago

The bodies of sprites that are outside the camera are not well positioned.

I have built this example to show what happens to me: http://jsfiddle.net/j3MYJ/

Its a map with two floors, the camera is fixed until you change the room. When moved between rooms, the enemy that stays in the lower room, is enabled or disabled. When you move back to the top room you can still see the enemy's bounding box, and you can collide with it.

I dont know if there is another way to temporally disable the body, more than do this:

    enemy.visible = (roomIndex != 0);
    enemy.active  = (roomIndex != 0);
    enemy.alive   = (roomIndex != 0);

Concrete steps to reproduce the bug:

1) Load the example. (http://jsfiddle.net/j3MYJ/) 2) Move left with cursors until fall down to the lower room. 3) Jump back to the upper room to see the enemy's bounding box.

Dumtard commented 10 years ago

enemy.body.enable = (roomIndex != 0);

casensiom commented 10 years ago

Great,that works!! Thank you very much!!