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 / Physics Shape Problem

Author
Message
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Nov 2014 17:39
Hi.

I create a floor(step) and add physics to it.then try to change phyasics shape to polygon for only cover fill area. but it no cover fill area and also cover empty area. how can fix this Problem?

green border in below picture show polygon shape.


Funnell7
13
Years of Service
User Offline
Joined: 8th Sep 2011
Location: UK, England
Posted: 28th Nov 2014 18:00
You need to use SetSpriteShapePolygon and manually configure the points. Baxslash put a very nifty tool together for this... Check this link out...

http://forum.thegamecreators.com/?m=forum_view&t=194938&b=48
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 28th Nov 2014 18:17
Also, you'll need to set individual physics sprites for each step as you can't have concave shapes (limitation of Box2d).

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Nov 2014 18:27
If it's a regular shape like this you could use SetSpriteShapeBox and AddSpriteShapeBox to add as many "steps" to each sprite as you like...

My tool is better for irregular shapes.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 28th Nov 2014 20:34
I don't want create separated setps and my step is a single image.
I try your tool but don't allow draw all part.

DavidAGK
AGK Developer
10
Years of Service
User Offline
Joined: 1st Jan 2014
Location:
Posted: 28th Nov 2014 22:06
Nice looking tiles....
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 28th Nov 2014 23:42
You can create as many convex shapes as you need for just one sprite.

If you insist on using my tool (despite the fact I've told you it isn't the best way to do this) it IS possible by creating multiple CONVEX shapes. Look at the commands I already told you to look at, they are the best way to do this.

I remember trying to explain things to you before and being told I was wrong a lot of times before I gave up. Trust me I am telling you the correct method for what you want is NOT my tool (although it is possible) but to understand using multiple shapes for one sprite using "SetSpriteShapeBox" and "AddSpriteShapeBox".

Look up the word "convex"...
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 30th Nov 2014 13:15 Edited at: 30th Nov 2014 13:16
my all sprites aren't step, like attached picture.

@baxslash

i don't know how can use with "SetSpriteShapeBox" and "AddSpriteShapeBox". please if possible create a little shape box with this function for understand that how can create it for other sprites.

thanks.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 1st Dec 2014 08:08
can anyone help me?
CJB
Valued Member
20
Years of Service
User Offline
Joined: 10th Feb 2004
Location: Essex, UK
Posted: 1st Dec 2014 11:09
Hi Behdadsoft. I must say, I have got to commend you for your efforts and enthusiasm!
When I suggested splitting up your physics shapes so you have one for each step, that wasn't a "Maybe you could do it like this" suggestion, but a "You absolutely must do it like this" suggestion. You said you didn't want to make separate steps. I'm afraid you have no choice if you want to use box2d physics. You need to loop up what the word convex means. A physics shape cannot have any angles going 'inwards'. Therefore, you must create separate physics shapes to fit into your landscape a bit like a jigsaw. You must break the landscape up into sections that fulfill the "no inward angles" requirement.

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Dec 2014 11:29 Edited at: 1st Dec 2014 16:55
Take a look at this image, it's an example of how you can create multiple shapes for one image:


Here is the Wikipedia page for convex shapes: http://en.wikipedia.org/wiki/Convex_and_concave_polygons

Convex = good
Concave = bad

Here's how the box commands should work for your steps sprite:


EDIT: I just tried to create an example of \"SetSpriteShapeBox\" and \"AddSpriteShapeBox\" but none of the \"AddSpriteShape\" commands work at all, they're broken. I will let Paul know....

EDIT 2: Actually it seems that you can only add multiple shapes to physics sprites. You just need to switch physics on for the sprite before adding multiple shapes. My mistake.

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 2nd Dec 2014 12:03 Edited at: 2nd Dec 2014 12:14
@CJB

Hi CJB and Thanks.

@baxslash

Thanks for example. now I know how can create convex shapes. I create spriteshapebox for another sprite. but I need make concave shape for some parts.but I don't know how to do it.

here is my Picture:



this is my code:



also I attached my sprite.

I need know concave shapes make decrease FPS?

Thanks.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Dec 2014 14:30 Edited at: 2nd Dec 2014 14:30
Look at my previous post again. It shows how to create concave shapes and no it should not affect performance (at least for sprites like these).

You cannot use SetSpriteShapeBox for shapes that are not boxes. You need to map out each corner of each polygon shape in a "clockwise" direction using the SetSpriteShapePolygon and AddSpriteShapePolygon commands as described.

Please try using these commands and see how you get on. Try to work out where each point should be:

Attachments

Login to view attachments
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 2nd Dec 2014 18:08 Edited at: 2nd Dec 2014 18:09
I tried but can't work with SetSpriteShapePolygon and AddSpriteShapePolygon.

Please if possible give me an example.

Thanks.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Dec 2014 09:30
Show me your code and I'll show you where you went wrong.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 3rd Dec 2014 12:33 Edited at: 3rd Dec 2014 12:34
this is my code:



I don't know how can create shape with it.

Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 3rd Dec 2014 14:04
Try looking through this code:
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 6th Dec 2014 21:13
Thanks baxslash.

but I can't understand how you created it.
I try make it myself, but when use one
I can't see what's happen. it don't like AddSpriteShapeBox() function.mean don't show anything for see what do at next step.there is any tip?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Dec 2014 15:02
Make sure you have physics switched on when adding shapes.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Dec 2014 15:15
SetSpritePhysicsOn(spr2,1) is exist. but seem should add 6 AddSpriteShapePolygon() that can see what's happen. and can't see anything with one AddSpriteShapePolygon ().
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Dec 2014 18:52
Show me the code you are using for the new shape. You need to set the number of points using the field I have "points" in. You must use AddSpriteShapePolygon once for each vertex (six times for a hexagonal shape.

Have you read the help file for this command? http://www.appgamekit.com/documentation/Reference/Sprite/AddSpriteShapePolygon.htm
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 7th Dec 2014 21:37 Edited at: 7th Dec 2014 22:07
it's your code but I disable some parts:



Quote: "Have you read the help file for this command? http://www.appgamekit.com/documentation/Reference/Sprite/AddSpriteShapePolygon.htm"


Yes I read it.

it's right that middle sprite have 6 points.



but why for every vertex used 6 point?



it's very Dumb for me and can't understand why use one or two AddSpriteShapePolygon() don't show anything.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 7th Dec 2014 22:24
You need to add the full number of points before anything will show so this:

... will show nothing but:

... will show a triangle


... will add the next point etc.

The shape is only complete when you have added the number of points specified.

Hope that makes sense!
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 8th Dec 2014 12:39 Edited at: 8th Dec 2014 13:35
According to SetSpriteShapePolygon help: "Setting a shape removes all other shapes assigned to the sprite and replaces it with this one."

I use this code, but also Spriteshapebox is exist. where is the Problem?



Attachments

Login to view attachments
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 8th Dec 2014 15:46
Try using just "SetSpriteShapePolygon" if you are only adding one shape.
Behdadsoft
15
Years of Service
User Offline
Joined: 7th Apr 2009
Location: Tehran-Iran
Posted: 9th Dec 2014 09:50
OK, Thanks baxslash.

I think understand how work with shapes.if there is question I ask.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 9th Dec 2014 11:28
Glad to help

Login to post a reply

Server time is: 2024-11-25 13:32:13
Your offset time is: 2024-11-25 13:32:13