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 / Set Sprite Shape Polygon help

Author
Message
JLMoondog
Moderator
15
Years of Service
User Offline
Joined: 18th Jan 2009
Location: Paradox
Posted: 25th Apr 2014 03:58
I\'m trying to rework my collision in my game so it\'s more accurate. I want to use the polygon shape for my player, but I\'m not sure I understand the command. I\'ve played around with it with no luck.



The documentation only covers the first two parameters, sprite ID and number of points in your polygon. The index and x,y aren\'t clear, or else I\'m reading the description wrong. Do I have to call this command for every point of the polygon and manually place it?

Thanks

Hockeykid
DBPro Tool Maker
17
Years of Service
User Offline
Joined: 26th Sep 2007
Location:
Posted: 25th Apr 2014 08:17 Edited at: 25th Apr 2014 14:19
Have you tried using?



This should attempt to auto generate a polygonal shape.

If you have and you're just not satisfied with it, here's how I believe SetSpriteShapePolygon works.


The documentation says "numPoints" can be anywhere from 2 - 12 points. So the "index" is a reference to each point and the X and Y are the position of the point (Probably based on the sprite's offset). AppGameKit will use this data to draw a line between each point to create the shape.

For example (Just made up the code on the spot, might not be 100% accurate):



EDIT: It's important to note that the index starts at 0

EDIT: Here's some test code that works:


Hopefully this helps


EDIT: I had some spare time so I decided to make this tool using DBPro. I've attached the download for it to this post. Hopefully it's useful.





Sean

Attachments

Login to view attachments
Van B
Moderator
22
Years of Service
User Offline
Joined: 8th Oct 2002
Location: Sunnyvale
Posted: 25th Apr 2014 17:39
I'm not sure if numpoints is actually the number of polygons... because I don't remember needing that when I made a 2D planet collision thing, it uses a lot of points and I'm sure I'd remember needing to keep track of them like that if I had to.

I'll see what I did last time and post again later - it tripped me up at first so it might be the exact same issue. Maybe worth doing a search as well, I'm sure I made a thread a while ago and Paul Johnston posted to explain how it works.

I am the one who knocks...

Login to post a reply

Server time is: 2024-11-25 04:27:15
Your offset time is: 2024-11-25 04:27:15