valueerror Posted November 24, 2014 Share Posted November 24, 2014 i have an object (see screenshot) that is my penguin.. i add a small white image that always points to the mouse pointer and changes it's length according to the distance between the pointer and the object.. so it looks like the penguin is strapped to the mousepointer with a white elastic rope... the rope is a simple phaser image (not a sprite and without physics) when the penguin moves fast the position of the rope is not in the center anymore.. depending on the velocity of the sprite the rope is off 5mm to 2cm.. ( I am using p2 physics )to keep the rope image always on the penguin i wrote the following 2 lines:this shouldn't be behind because its updated on every frame - its running in the update loop and keeps the rope anchor at the penguins (hitSprite) center (but it DOESN'T )rope.x = hitSprite.x; rope.y = hitSprite.y;also in the update loop there is the length and angle calculation: (mouseanchor is the point where the mouse is) rope.angle = angleBetween(mouseAnchor,hitSprite)+90;rope.height = distanceBetween(mouseAnchor, hitSprite);i'm using custom functions to calculate the angle and the distance and it works very well when the penguin is moving very slow... also it looks very choppy when the penguin is moving fast.. it feels like the rope image is only updated every 10 time ?? !! why is the position update of the rope so much delayed ? thx in advance! Link to comment Share on other sites More sharing options...
valueerror Posted November 25, 2014 Author Share Posted November 25, 2014 i made a cuple of tests and found out the REAL issue. the physics body is totally off. have a look at the screenshot ! so my flexible rope is actually pointing towards the correct point.. the center of the physics body.. but the center of the body is not the center of the sprite if the sprite is moving fast.. puhh.. unfortunately i alread point to the sprite.x not the sprite.body.x and as you can see in the attachment (my console log where i log body.x and sprite.x) they are always the same.. but still the sprite is painted on a different position.. jpdev 1 Link to comment Share on other sites More sharing options...
jvinhit Posted December 20, 2015 Share Posted December 20, 2015 hi @valueerror, you can help me ! i made a cuple of tests and found out the REAL issue. the physics body is totally off. have a look at the screenshot ! so my flexible rope is actually pointing towards the correct point.. the center of the physics body.. but the center of the body is not the center of the sprite if the sprite is moving fast.. puhh.. unfortunately i alread point to the sprite.x not the sprite.body.x and as you can see in the attachment (my console log where i log body.x and sprite.x) they are always the same.. but still the sprite is painted on a different position.. Link to comment Share on other sites More sharing options...
Recommended Posts