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.

Newcomers AppGameKit Corner / Is there a tool or a simple way to set a Polygon collision shape on a sprite?

Author
Message
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 26th Oct 2020 16:55
I'm struggling to work out this out in coordinates and wondered if there was an easy way to do this? It feels like a lot of trial and error to set up, but maybe I'm missing something!

I've played around with AddSpriteShapeBox and got nowhere with it and then tried SetSpriteShapeChain which is easier to follow but still tricky to get right.

Many thanks in advance.
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 26th Oct 2020 18:08 Edited at: 31st Oct 2020 21:36
**Update**
I've updated this simple code to now write to a file (assumes you're running Windows) You still have to manually load the image by changing the code and set its size and position to where you want it.
It always has a line drawn from 0,0 something I've not been able to figure out why, so would love to know how to fix that, but if you click and draw a shape around your sprite, the code that gets generated works as expected. Has saved me hours of messing about with coordinates. You also have to set the Virtual Resolution to the same as your project.

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 26th Oct 2020 20:11 Edited at: 26th Oct 2020 20:14
since you asked about Polygons, see ShapeUp. there are some bad links for it around the forum (including the first post, there), so i attached it to the Resource thread with reference.

meanwhile, don't forget to close your code tags (which i added for you)
[My Itch.io Home] [#LowRezJamAGK2020]
[AGK Resource Directory] [TGC @ GitHub]
[CODE lang=AGK] YOUR CODE HERE [/CODE]
[VIDEO=youtube] VIDEO ID [/VIDEO]
[Google Forum Search]
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 26th Oct 2020 20:41
Many thanks Nomad!! This is exactly the thing I need Got it on the code tag.
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 31st Oct 2020 21:33
ShapeUP doesn't do all I need it to, so I went back to my own code and updated that so as it now writes a file for SetSpriteShapeChain. Its still basic but can save a lot of time.
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 31st Oct 2020 22:06 Edited at: 31st Oct 2020 22:12
What is it that you need ShapeUp to do? Can you please specify, so that I can take into account your needs into the upgraded version of ShapeUp. Here is the link to the progress works on ShapeUp. Please check whether that what you require is available, or there is something that you need this tool to do, I want to know. Thank you.
????????
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 31st Oct 2020 22:46
Will take a look tomorrow Lupo, off to bed right now. But basically the version that Nomad linked me did not allow me to set shapes on the shapes I needed. e.g. a C shape for example.
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 1st Nov 2020 03:14
C shapes are convex, that breaks one of the rules for creating polygon shapes. The way you have to do it, is create multiple ploygons of concave shape to create your convex shape. ShapeUp can do that, no problem. To make the upgraded ShapeUp create convex shapes in the form of multiple triangles is possible, would be an interesting further update to the works, not a fundamental one at present, more a future feature.
????????
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 2nd Nov 2020 13:01
Hi Lupo, thanks for confirming that about Polygon shapes - I thought that must be the case. That is why I went with using SetSpriteShapeChain because in most instances I do need to close the loop.
I understand what you mean about creating multiple polygons to create the concave shape. Basically chop up the image to apply shapes and then align them to make the original sprite.
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 2nd Nov 2020 19:42
Hi Paxi. You can close the Chain shapes, no problem, your last point has the same coordinates as your first point, that is all.

Your image does not need to be chopped up, you just create the polygon shapes, one by one and some of the points of the previous shapes become the points to continue drawing the next shapes and so on until you fill the entire geometry of the relevant image in the image. I did a quick demo for you to see how you can do this using ShapeUp. I also, used the edit mode to show the present anomally with ShapeUp edit, that it alters the coordinates of the first point of the first shape for some reason. After it alters it once, then you can readjust it, and then it does not alter it anymore. Will need to fix this at some point. Take care.

The demo for creating convex shapes using ShapeUp:

????????
Paxi
4
Years of Service
User Offline
Joined: 18th Sep 2020
Location:
Posted: 3rd Nov 2020 14:21
AHH! Yes I get it now! Thanks so much Lupo. Great that I don't need to chop up the image In my other post, I meant to say "I don't need to close the chain" not DO.
Thanks again, the video is perfect. I'm onto a new problem at the moment, but I'll be back to this soon!
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 4th Nov 2020 21:59 Edited at: 4th Nov 2020 21:59
There was music with that video, but for some reason it did not record. Must have been a very dull experience to watch. With music, a person has an option to listen or to mute, without you have no option. Forgive me.
????????

Login to post a reply

Server time is: 2024-11-23 08:23:31
Your offset time is: 2024-11-23 08:23:31