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 / [BUG} SetSpriteShapePolygon()

Author
Message
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 8th Aug 2018 05:08 Edited at: 8th Aug 2018 05:25
I'm not sure if this is busted for all cases but it no longer works for a line (Last working in AppGameKit-V2017.09.25-Windows)

Run this code using a post V2017.09.25 compiler and you will see a small green square.

Run this code using the V2017.09.25 compiler and you will see a green line

smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 8th Aug 2018 11:03
i think you're supposed to use the polygon command with index above 0 (0 is a special delete all case).
this creates a line for me
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 8th Aug 2018 11:18 Edited at: 8th Aug 2018 11:19
Thanks smallg that will work for me, thanks very much, however it did work on the previous version AND the documentation says the index starts from zero;

Overrides the current auto generated shape for use in collision detection, hit testing, and physics. A shape can be set without turning physics on, and by default all sprites are set to use the box shape, which is the fastest to setup. The polygon is defined by a set of points (between 2 and 12) relative to the current sprite's offset. For example, a point of 0,0 would be centered on the sprite's offset point, any other value will be offset from this point. Points are defined one at a time by calling this command multiple times, with index starting at 0. Once the index equals numPoints-1 then the shape will be created using the previously defined points. Once you start defining points you must complete the process by reaching index=numPoints-1 before defining points for any other shape.
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Aug 2018 12:03 Edited at: 8th Aug 2018 12:05
Smallg: Your thinking of the shapeID being set to zero which when its set to zero it deletes all shapes and replaces them with a new one
If you define a polygon and use indexes 0,1,2 then it works fine so index 0 is fine

In your case above there are 3 points ...even if you only set 2 of them...index 0 is at 0,0

Try:
SetSpriteShapePolygon(s, 3, 1, -100.0, -100.0)
SetSpriteShapePolygon(s, 3, 2, 100, -100)

and the index 0 point appears (you have a triangle - not a line)....your just "hiding" index 0 in your example as the zero index happens to be on the line

The point im trying to make is that at least 3 points are needed for a polygon shape despite the docs saying 2 or more.


As for the command having a "bug"....following release V2017.09.25 the sprite chain commands were added

"Added SetSpriteShapeChain and AddSpriteShapeChain to create 2D chain shapes, these are the most suitable shape for 2D terrain"
"Added ChainShape example to the Physics folder to demonstrate a simple 2D terrain"

A 2 point sprite chain is fine and will work and create a line. A polygon needs to have at least 3 points to be valid though
smallg
Valued Member
18
Years of Service
User Offline
Joined: 8th Dec 2005
Location: steam
Posted: 8th Aug 2018 20:42
yh i ignored 0 because 0 and 1 alone didn't work but your explanation makes more sense that you need 3 points though a polygon is normally a triangle when referred to by modelling apps etc.
so it's creating a box because it ignores the polygon shapes until there is a valid shape defined? that's actually pretty neat, i'm impressed AppGameKit handles user error so well
life's one big game
spec= 4ghz, 16gb ram, AMD R9 2700 gpu
puzzler2018
User Banned
Posted: 8th Aug 2018 21:22 Edited at: 8th Aug 2018 21:23
i been reading the Tier 2 coding on github and indeed there is a huge amount try and catches producing error alerts - all that means is a very well developed programmer take my hat off and bow to Paul anyday of the week.
blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 8th Aug 2018 22:02
My problem is;
A) The documentation says from zero and 2 or more points
B) If i change it to index 1 & 2 is it going to break later on when another release comes out?
Bengismo
7
Years of Service
User Offline
Joined: 20th Nov 2017
Location: Yorkshire, England
Posted: 8th Aug 2018 23:08
Quote: "My problem is;
A) The documentation says from zero and 2 or more points
B) If i change it to index 1 & 2 is it going to break later on when another release comes out?"


Id just use the sprite chain for 2 points OR use SetSpritePolygon but set 3 points so it works like above.

Login to post a reply

Server time is: 2024-11-27 10:09:12
Your offset time is: 2024-11-27 10:09:12