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
Posted: 23rd Oct 2011 13:30
Hi again

Part of the problem solved. The function is:

static void SetSpriteShapePolygon( UINT iSpriteIndex, UINT numPoints, UINT index, float x, float y );
Posted: 23rd Oct 2011 14:01
edited.
Posted: 23rd Oct 2011 16:13
edited
Posted: 26th Oct 2011 8:16
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.
Posted: 27th Oct 2011 2: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
Posted: 27th Oct 2011 10:40
Thanks for your reply pedrolbs. Yes, We'll wait...
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 )
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.