Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / SetSpriteShape not forming full shape

Author
Message
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 20th Aug 2013 00:52 Edited at: 20th Aug 2013 00:56
hello
i have an physics sprite in this shape:



but the shape collision comes out lke this



i have noticed that once the collision box has gone out it does not go back in

i have set SetPhysicsMaxPolygonPoints to 12 ( the max ) but it did not change anything

are there any solutions to this problem?
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Aug 2013 05:01
A physics sprite cannot have a concave surface. That is why the collision box is showing what it does.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Aug 2013 09:36
maybe with AddSpriteShape...
SetPhysicsDebugOn should show the shape at runtume.
Grook
AGK Backer
12
Years of Service
User Offline
Joined: 22nd Jun 2012
Location: Lancashire, England
Posted: 20th Aug 2013 11:58
As AL says you can't have a single shape which is concave. You will need to create multiple shapes to get around this as Markus says. Do a search on here for the shape up(?) app written by baxslash, that'll solve your problem.

"Happiness is contrary to the human condition" --White (to Black)
JimHawkins
15
Years of Service
User Offline
Joined: 26th Jul 2009
Location: Hull - UK
Posted: 20th Aug 2013 14:20
It's one of the (many) stupid limitations of OpenGL. It's not TGC's fault.

-- Jim DO IT FASTER, EASIER AND BETTER WITH AppGameKit FOR PASCAL
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 20th Aug 2013 15:26
i dont think shape up will help as it cannot do concave shaped
i tried using AddSpriteShapePolygon but as soon as i got to the concave part the shaped vanished

it there a way to maked an object part not able to have a collision. eg making a circle infront of the rectangle to make a concave shape.
ive included an image of what i mean to download/view
would that work and can it be done

Attachments

Login to view attachments
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Aug 2013 16:42
Quote: "it there a way to maked an object part not able to have a collision."

No. Collision is checked on each sprite (with physics enabled).

ShapeUp is can be used to create two sprites for your original posted 'image', which has only straight lines. But if you want a true curve, than it might not work.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 20th Aug 2013 17:47
i have finaly got shape up to work! before when i edited the shape the secondary shape moved aswel

thanks everyone
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 20th Aug 2013 18:23
what i mean with addshape was try to split the one shape you showed above
in two "triangle" shapes that looks the same you need.
samqweqwe
11
Years of Service
User Offline
Joined: 7th Apr 2013
Location:
Posted: 31st Aug 2013 20:23 Edited at: 31st Aug 2013 20:30
is it possible to make collision shapes made with addSpriteShapePolygon to scale with the object?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Sep 2013 14:24
Quote: "i dont think shape up will help as it cannot do concave shaped"

Not quite true. You can add multiple convex shapes to one sprite using ShapeUp. It's the only way to get a concave shape using Box2D.

You may need to use a number of shapes added to the one sprite to get the shape depending on how big the concave part/s are.

"Here I am trying to do some good for the world..." - Fluffy Rabbit
MarcoBruti
13
Years of Service
User Offline
Joined: 20th Nov 2011
Location: Caput Mundi
Posted: 2nd Sep 2013 17:13
or you can simply overlap 2 or more convex sprites in order to make a concave sprite. That is what I did with my app App-In-Ball in order to simulate curved elements. Then you can scale as you like the resultant sprite.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Sep 2013 17:28
That is another way I hadn't thought of that would make it easier for games that have to fit the aspect ratio of the screen, nice thinking! Just don't add overlapping shapes to a single sprite as this causes problems.

"Here I am trying to do some good for the world..." - Fluffy Rabbit

Login to post a reply

Server time is: 2024-11-24 21:01:51
Your offset time is: 2024-11-24 21:01:51