Moving SegmentShape

Official forum for the Chipmunk2D Physics Library.
Post Reply
bass
Posts: 3
Joined: Thu Jul 25, 2013 4:34 am
Contact:

Moving SegmentShape

Post by bass »

Hello,

I'm using Chipmunk-js for my game to be compatible with all devices.
I'm trying to move a sensor SegmentShape to detect collisions with it and act upon them, here's what im doing :

Code: Select all

//Initialisation
vortex.shape = new cp.SegmentShape( game.space.staticBody, game.player.getPosition(), pos,30);

//Move endpoints
vortex.shape.b=pos;
vortex.shape.n = cp.v.perp(cp.v.normalize(cp.v.sub(vortex.shape.b, game.player.getPosition())));
This is working for html5 but when i run it on iOS it stops working (the shape gets initialised but cannot be moved afterwards). Whats the way around this to make it compatible with iOS ? :?
User avatar
slembcke
Site Admin
Posts: 4166
Joined: Tue Aug 14, 2007 7:13 pm
Contact:

Re: Moving SegmentShape

Post by slembcke »

Shapes that are added to a static body are static and their collision detection information is not automatically updated each frame.

You have two options:
1) Attach the shape to a rogue body, a non-static body that is not added to the space. The body's position and velocity won't be updated each frame unless you do it yourself, but the shape's collision detection information will.
2) Call one of the cp.spaceReindex*() functions to manually tell Chipmunk to update the shape's collision detection information.
Can't sleep... Chipmunks will eat me...
Check out our latest projects! -> http://howlingmoonsoftware.com/wordpress/
Post Reply

Who is online

Users browsing this forum: No registered users and 11 guests