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 / Rotate Sprite and Display Aspect

Author
Message
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 23rd Mar 2014 18:00
Changing the offset to be off-centre and rotating a sprite misbehaves when using e.g. SetDisplayAspect(-1)

I read about using GetDisplayAspect() to correct this, but I can't seem to get anywhere with adjusting the rotation point to behave correctly.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 23rd Mar 2014 20:22
Can you show the code you are using? We need more information to see how you are using the commands.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 23rd Mar 2014 21:02
Just something like:



where the sprite may be 140x200 in size, so normally would rotate about 70x100.

If I have SetAspectRatio(-1) then the offset is wrong.
I have a virtual res of 1024x768, but the fullscreen res is 2560x1440.

I'mm pretty sure it's an aspect thing, as a GetSpriteHeight() returns a bigger number than it actually is..

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 23rd Mar 2014 23:04
There is no 'SetAspectRatio' command. I am assuming that you mean 'SetDisplayAspect'.

That command is used with the default percentage system, not the virtual resolution system.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 24th Mar 2014 00:11
Yes, that's it.
Yes, I know, but it's the best way for me to get full screen on PC for 16:9 and 4:3. Hasn't caused me a problem before (although I did encounter this offset issue before, but I worked around it).

This time I can't though as I need to perform a central rotation followed by an offset rotation.

nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 24th Mar 2014 00:14
I'm guessing that there's some relational calculation between either the GetSpriteHeight() in the new stretched resolution vs the 1024x768 virtual resolution or applying the GetDisplayAspect() somewhere..

nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 24th Mar 2014 01:34
OK, I have made some progress, but another problem remains.

If I use GetSpriteXFromPixel() and GetSpriteYFromPixel() I can solve the rotation point issue regarding resolution - yay!

However, now I have a problem with the positioning. Essentially, I need to reproduce the MoveObjectLocalX() style commands to work with sprites?

nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 24th Mar 2014 02:20
OK, managed to fix it with a bit of a hack using GetWorldXFromSprite() and GetWorldYFromSprite()

Will probably write an equivalent function set for movelocal() at some point, as it would be REALLY useful!

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 24th Mar 2014 03:26
The 'MoveObjectLocalX' command is for 3D stuff.

Are you working in 2D or 3D?

Have you decided to work in the percentage or virtual resolution system?

If you are working in virtual resolution, you should be able to use GetSpriteX or GetSpriteXByOffset (and the 'Y' versions) to get the position of the sprite.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
nz0
AGK Developer
17
Years of Service
User Offline
Joined: 13th Jun 2007
Location: Cheshire,UK
Posted: 24th Mar 2014 10:21
Yes, I know it's a 3D command, but a variation would be useful in 2D.
At the moment I'm working in a mixture of 3D and 2D and sharing some interesting rotational data between two representations.

One is a 3D tank with an offset turret (rotation over rotation) and HUD information which is the 2D version to show orientation.

The GetWorldXFromSprite() and GetSpriteXFromPixel() are commands I've not looked at before, but were essential in this case.

Login to post a reply

Server time is: 2024-11-25 03:48:59
Your offset time is: 2024-11-25 03:48:59