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 / SetSpriteShapePolygon help needed

Author
Message
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 23rd Oct 2011 13:03
SetSpriteShapePolygon

Hello. I'm trying to use SetSpriteShapePolygon but it seems there is an error in the documentation. Can anyone tell me the correct parameters for the function?

Another question is the order of the coordinates in the array. In the sense of clockwise?

Does it appear (SetSpriteShapePolygon) in any of the example projects?

Thanks in advance
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 23rd Oct 2011 13:30 Edited at: 26th Oct 2011 08:21
Hi again

Part of the problem solved. The function is:

static void SetSpriteShapePolygon( UINT iSpriteIndex, UINT numPoints, UINT index, float x, float y );
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 23rd Oct 2011 14:01 Edited at: 26th Oct 2011 08:20
edited.
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 23rd Oct 2011 16:13 Edited at: 26th Oct 2011 08:20
edited
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 26th Oct 2011 08:16 Edited at: 26th Oct 2011 08:25
After three days fighting with the command SetSpriteShapePolygon, and wasting time, I posted the error in the Google's section. Source code included for test With the ID 117.

[href]http://code.google.com/p/agk/issues/list [/href]

If someone believes that it's an error in my code, please let me know.

See you.
pedrolbs
13
Years of Service
User Offline
Joined: 18th Aug 2011
Location: PT
Posted: 27th Oct 2011 02:35
I believe you are right Javier, I had similar problems with the isometric pathfinding app, from letting AppGameKit try to find the tile shape automatically with 12 points with SetPhysicsMaxPolygonPoints to setting my own points manually in different ways I tried it all and still ended up not understanding why there were areas of the tile being ignored by GetSpriteHit.

One of the last version's updates referred something like "Fixed polygon hit test bug" but the problem I had remains.

Hopefully this will be fixed in a future version
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 27th Oct 2011 10:40
Thanks for your reply pedrolbs. Yes, We'll wait...
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 27th Oct 2011 21:00
The polygon must be convex, to create more complicated shapes you need to use compound shapes containing more than one polyon, circle, or box. You must also not duplicate any points (first and last points in your example are the same)

The following set of points are convex and works

SetSpritePosition ( dum_spr_RWALL01_ID,0,0 )
SetSpriteShapePolygon( dum_spr_RWALL01_ID, 4, 0, 1.0, 49.0 )
SetSpriteShapePolygon( dum_spr_RWALL01_ID, 4, 1, 40.0, 40.0 )
SetSpriteShapePolygon( dum_spr_RWALL01_ID, 4, 2, 90.0, 50.0 )
//SetSpriteShapePolygon( dum_spr_RWALL01_ID, 5, 3, 65.0, 52.0 )
SetSpriteShapePolygon( dum_spr_RWALL01_ID, 4, 3, 37.0, 74.0 )
//SetSpriteShapePolygon( dum_spr_RWALL01_ID, 6, 5, 1.0, 49.0 )
JavierTF
14
Years of Service
User Offline
Joined: 15th Feb 2010
Location: Going out, to the right
Posted: 27th Oct 2011 23:51
Paul, THANK YOU! The clarification about convex polygons has been essential. That was the key.

I filed last coordinate in a last attempt to make it work.

It might be interesting to add your explanation in the documentation!

Thanks again.

Login to post a reply

Server time is: 2024-11-22 10:52:14
Your offset time is: 2024-11-22 10:52:14