ojn17041991 Posted June 16, 2017 Share Posted June 16, 2017 I have a series of platforms and under a certain condition, I need them all to move to a different position. The new position is not fixed, it depends on the circumstances and the platform's current position. I tried setting platform.x/y and it moves the sprite to the correct position, but the collision box of the sprite seems not to have moved. I tried setting platform.body.position.x/y (body is enabled), but nothing happens; the collision boxes remain in their original position. I want this to be an instant change in position, so velocity (which I believe moves both the sprite and the collision box) won't really work. Could anyone tell me how to move the collision box of a sprite, either WITH the sprite itself, or independently so I can at least align them manually? EDIT: I realised I have body.moves set to false, which seems to be causing the synchronisation between the sprites and their collision boxes. The problem I have is that I can't set body.moves to true, because if I do, setting the positional values ONCE just seems to happen on every frame (for whatever reason). There must be a way of setting a one-time positional value with body.moves set to true, but if there is I sure can't find it. Link to comment Share on other sites More sharing options...
samme Posted June 17, 2017 Share Posted June 17, 2017 That should work regardless of body.moves. There are some times (postUpdate–preUpdate) when setting body.position is ineffective and you need to use sprite.reset(x, y) instead. But if the body is never following the sprite, it sounds like something else if wrong. Otho 1 Link to comment Share on other sites More sharing options...
samme Posted June 17, 2017 Share Posted June 17, 2017 Also make sure you haven't set body.enable=false. Link to comment Share on other sites More sharing options...
Recommended Posts