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 / [SOLVED] SetSpriteShapePolygon help please

Author
Message
Abiz
12
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 13th Oct 2020 16:37
I have tried 500 permutations, leading to either "no shape", "a box", or two shapes.

In all cases where it succeeds in adding (a second shape) , the shape only works on collisions and NOT on physics.



Maybe I'm doing something wrong, but it is simply not working as documented.

I need to assign a shape to a sprite that is NOT related to the image of the sprite, but pre-defined by me.

There are no working examples that I can find.

Please help
James

The author of this post has marked a post as an answer.

Go to answer

Virtual Nomad
Moderator
18
Years of Service
User Offline
Joined: 14th Dec 2005
Location: SF Bay Area, USA
Posted: 13th Oct 2020 17:05 Edited at: 13th Oct 2020 19:03
This post has been marked by the post author as the answer.
at a glance:
AddSpriteShapePolygon wrote: "
...must be added after a sprite has been set to use physics."

IE, SetSpritePhysicsOn() before Adding the shapes?

Actually:

...doesn't jibe. you should be using SetSpriteShapePolygon for every Index in order to define the shape. So, something like:

...to set the BASE shape of the Sprite.

then, when you want to add ADDITIONAL shapes, begin with AddSpriteShapePolygon() and define the remaining points with continued use of AddSpriteShapePolygon()s while increasing the Index for each until complete.

point: SetSpriteShapePolygon() is completely separate from AddSpriteShapePolygon(); they are not to be used together to form the SAME shape.

i hope that makes sense?

working example of multiple Shapes for the Table in TableRunner (using Chains vs Polygons):
[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]
Abiz
12
Years of Service
User Offline
Joined: 14th Nov 2012
Location: Amsterdam
Posted: 13th Oct 2020 23:57 Edited at: 13th Oct 2020 23:57
Quote: "point: SetSpriteShapePolygon() is completely separate from AddSpriteShapePolygon(); they are not to be used together to form the SAME shape.

i hope that makes sense?
"

Virtual Nomad thank you so much for your answer.
It makes total sense, and you are right, I did the same with CHAINS.

Will try again, although chains seem to make much more sense, then polygons
Lupo4mica37
4
Years of Service
User Offline
Joined: 1st Jun 2020
Location:
Posted: 14th Oct 2020 00:52
Polygon shapes need to be created clockwise, meaning the order of points placed and the shape has to be concave. Chain shapes are simply lines joined by points, there is no area except the lines themselves. I am upgrading Baxslash's AppGameKit tool for making sprite shapes to make the entire process effortless, so that you visually can draw your shapes and then the data is exported into a file that you can use with a function to make generate your shapes for whatever sprite images in your own project. Supports the creation of polygon, box and chain shapes. Link to thread.
????????

Login to post a reply

Server time is: 2024-11-21 22:29:08
Your offset time is: 2024-11-21 22:29:08