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.

Newcomers AppGameKit Corner / A question about setspritepositionbyoffset

Author
Message
Danishly
4
Years of Service
User Offline
Joined: 10th Aug 2015
Location: Norway
Posted: 13th Aug 2015 20:46
Hello! Can someone tell me the main difference between these 2 commands? And when one usually uses which one?

Thank you!

Just started - Much to learn
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 13th Aug 2015 21:33 Edited at: 13th Aug 2015 21:33
Do you mean setspriteposition (1) and setspritepositionbyoffset (2)?

(1) uses the top left corner of the sprite.

(2) uses the centre of the sprite by default.

You can use either of these, it is personal preference, or the circumstance you are using it in that would decide.

BUT you can also change the offset using setspriteOffset(). The offset can be anywhere, including outside of the sprite itself. In this case you can be a bit more creative. For example you could set an offset that relates to something else on the screen, and use it to rotate the sprite around that other entity.

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt
Danishly
4
Years of Service
User Offline
Joined: 10th Aug 2015
Location: Norway
Posted: 13th Aug 2015 22:58
Ah, yes you're right, I mean setspriteposition and setspritepositionbyoffset.

And thank you for the answer! So if I get it right, the difference is what place/which pixel on the sprite that will appear at said position?

Just started - Much to learn
BatVink
Moderator
16
Years of Service
User Offline
Joined: 4th Apr 2003
Location: Gods own County, UK
Posted: 14th Aug 2015 01:21
Yes, that's correct

Quidquid latine dictum sit, altum sonatur
TutCity is being rebuilt

Login to post a reply

Server time is: 2019-10-18 01:09:43
Your offset time is: 2019-10-18 01:09:43