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 / SetSpriteSize() by world axis?

Author
Message
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Aug 2017 12:56 Edited at: 11th Aug 2017 13:07
Hey,

Imagine this scene, you have a spaceship sprite (an arrow in the image below) and you rotate it 90 degrees. You then change the width of the sprite and it scales according to the sprites view of what it's width is.
That's good. That's what you want in a game.
However, I'm writing a tool for AppGameKit, in AppGameKit and I need to set the width of the sprite ignoring it's current orientation - so screen aligned.

In the image below:
Top left is the original sprite,
Top right is rotated 90 degrees,
Bottom left is the rotated sprite that has had its width changed,
Bottom right is how I would like to change the width of the sprite - useless for games but essential for design tools.



A command like FixObjectPivot() but for sprites would be handy or an optional parameter in SetSpriteSize() and SetSpriteScale() that makes the commands screen aligned.
Or maybe there is already a way to do what I want but I'm not seeing it.

Any suggestions?

Attachments

Login to view attachments
Mobiius
Valued Member
21
Years of Service
User Offline
Joined: 27th Feb 2003
Location: The Cold North
Posted: 11th Aug 2017 13:13
You could try rotating the image textures UV coordinates, rather than the sprite?
Signature removed by mod because it's larger than 600x120... please resize and try again.
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Aug 2017 14:15
Thanks for the suggestion but that wouldn't work.
It would switch the problem from scaling a rotated sprite to rotating a scaled sprite.
If I were to only rotate the UVs then a tall thin sprite would always be a tall thin sprite and that's no use.
Markus
Valued Member
20
Years of Service
User Offline
Joined: 10th Apr 2004
Location: Germany
Posted: 11th Aug 2017 14:36 Edited at: 11th Aug 2017 14:38
hmm, maybe just rotate/scale as you like a image from original with the memblock commands?
and using drawsprite with a selected image instead of createing all sprites.

if your rotation is only in 90 degree steps you can exchange width and height.
AGK (Steam) V2017.07.19 : Windows 10 Pro 64 Bit : AMD (17.4.4) Radeon R7 265 : Mac mini OS Sierra (10.12.2)
Scraggle
Moderator
21
Years of Service
User Offline
Joined: 10th Jul 2003
Location: Yorkshire
Posted: 11th Aug 2017 15:52 Edited at: 11th Aug 2017 18:14
Quote: "if your rotation is only in 90 degree steps you can exchange width and height."

It isn't. The rotation could be any angle.
I can't imagine that rotation with memblock commands would be feasible either, not unless the sprites were perfect squares, which they are not.

I'm still open to suggestions though. If someone can think of a way to rotate a memblock of arbitrary proportions then I'm all ears!

So far, in the absence of a FixSpritePivot() command my only thought is to create a kind of FixSpritePivot() function which would be very slow. It would involve pasting the rotated sprite then using GetImage() to grab it and creating a new sprite from that image, deleting the original one and setting the new ones spriteID to that of the now deleted one.

[Edit] That isn't as straight forward as I thought either. In order to use GetImage() I'd still have to know the screen dimensions of a rotated sprite. I'm sure that is something that can be calculated, I just don't know how to do it ... time to consult my books

Login to post a reply

Server time is: 2024-11-24 09:24:01
Your offset time is: 2024-11-24 09:24:01