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 / Going bonkers with sprite angles and their calls ......

Author
Message
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 4th Apr 2013 23:38
I really am having troubles understanding the behavior of the command GetSpriteAngle() and I'm wondering if it's a local vs world coordinate thing that I know I'm just missing somehow....

GetSpriteAngle() seems to operate in two different worlds where one has 360 degrees in a circle, and the other splits the circle up into halves where 0 to 180 degrees is the "lower" 1/2 of the circle (going from +0:right to +180:left) and the "upper" 1/2 of the circle is -180 degrees down to 0 (going from -180:left to -0:right).

Here's the problem: I find that when I write any standard code to rotate a sprite around it's default center rotation point (no offsets) using SetSpriteAngle() and then use GetSpriteAngle() to display the exact angle in degrees it will display the coordinates of the 360 degree coordinate system during the actual physical rotation on the screen (during real movement), but when it stops moving it reverts to the +180/-180 degree coordinates which it returns as the garnered angle.

All I use to display the angle is a simple command much like this:
Print("Sprite Degrees: "+Str(GetSpriteAngle(MySpriteID)))

I know I'm missing something simple but I just can't see it at the moment ... any suggestions would be greatly appreciated ...

----
From the Desk of Prof Versaggi ...
Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 4th Apr 2013 23:59
Hi ProfVersaggi,

This is a result of physics vs non physics sprites.

For some reason the box2d physics uses a 0 to 180 and -180 to 0 based degree system and non physics sprites use a 0 to 360 degree system.

It will just take a little extra math depending on whether your sprites are using physics or not to make the return values of getspriteangle() compatible.
ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 5th Apr 2013 00:07
Excellent! I'm using physics sprites in this case ... what needs to be done to make them behave properly? Are there any links, references, etc or a decent example? Many thanks in advance!

----
From the Desk of Prof Versaggi ...
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 5th Apr 2013 00:49
Can you not just use a dbp style wrapangle command? (If it exists in agk)

I live for video games! (And beers, and football, and cars!)
See what I live for here: [url]http:\\www.TeamDefiant.co.uk[/url]
Grumpy Jedi
14
Years of Service
User Offline
Joined: 16th Jan 2010
Location:
Posted: 5th Apr 2013 01:48
To convert a physics sprite to the 360 system or vice versa use something like this.

ProfVersaggi
12
Years of Service
User Offline
Joined: 6th Apr 2012
Location: Maastricht Netherlands / Chicago, USA
Posted: 5th Apr 2013 13:54
Thank you Grumpy Jedi ... I was wondering what that calculation looked like ...

----
From the Desk of Prof Versaggi ...
Marl
12
Years of Service
User Offline
Joined: 19th Nov 2011
Location: Bradford, UK
Posted: 5th Apr 2013 21:24
Quote: "Can you not just use a dbp style wrapangle command? (If it exists in agk)"


As it happens;


from http://forum.thegamecreators.com/?m=forum_view&t=196171&b=41&msg=2340418#m2340418

Login to post a reply

Server time is: 2024-05-06 05:37:16
Your offset time is: 2024-05-06 05:37:16