hellos3b Posted December 21, 2014 Share Posted December 21, 2014 I have a strange issue, which I wonder if it's a bug or some optimization in phaser that's not getting triggered I have a unit I click & select, and when I click another tile I set his (x,y) to the tilethis.entity.updatePosition(tile.getX(), tile.getY());// entityupdatePosition: function(x, y) { if (this.sprite) { this.sprite.body.x = x; this.sprite.body.y = y - 64; } },The numbers/values are right in console (I see them get updated), but until I hold down the mouse and drag the view, he doesn't change. I'm using arcade physics I'm not using the Phaser camera, I wrote my own input handler, and it doesn't do anything different than the above code does. Example: if (this.game.input.activePointer.isDown) { if (this.game.origDragPoint) { // move the camera by the amount the mouse has moved since last update var movex = this.game.origDragPoint.x - this.game.input.activePointer.position.x; var movey = this.game.origDragPoint.y - this.game.input.activePointer.position.y; this.tileManager.drag({ x: movex, y: movey }); }}and all tileManager.drag does is iterate through active tiles and update their positions// tileManager.drag -> tileManager.updateTiles() -> for (var k in view) -> view[k].drag()drag: function() { if (this.sprite) { this.sprite.body.x = this.getX(); this.sprite.body.y = this.getY(); } if (this.entity) { this.entity.updatePosition(this.getX(), this.getY()); } // Check if tiles are in scope, otherwise destroy this.checkRender(); },Is there a way to force the sprite to update the body manually? This is the second time I've ran into this issue. The first time was when I wrote a centerCameraOnTile(x,y), if I set it to move across the map it worked, but if I moved it only a couple tiles up I wouldn't see the tiles move unless I clicked and dragged. That one was fixed by running a blank drag event on game.update(), which has no logic behind it but it seemed to workthis.tileManager.drag({x:0,y:0}); Link to comment Share on other sites More sharing options...
spencerTL Posted December 21, 2014 Share Posted December 21, 2014 Try using body.reset(x,y) . Directly setting body position, from what I've seen in other threads, often seems to cause problems as it fights with the physics engine. Link to comment Share on other sites More sharing options...
Recommended Posts