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 / Sprite Resizing Function

Author
Message
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 11:34
i have 20 sprites assembled together to form a character.

I want to resize down ALL sprites, and reposition the sprites X & Y positions to keep the character assembled together the proper way.

I am using SetSpriteScale right now, but I can't get the sprites to reposition themselves when I scale them down.

I think there was such a function proposed maybe by Baxslash, but I cannot find it.

Any help?
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Aug 2012 12:03
I don't have a function for that but is should be relatively simple. Just get a datum point such as the position of one of the sprites and get the distance in x and y of each sprite in turn from that datum. Then scale each of those values and reposition them relative to the datum point.


this.mess = abs(sin(times#))
Cliff Mellangard 3DEGS
Developer
18
Years of Service
User Offline
Joined: 20th Feb 2006
Location: Sweden
Posted: 1st Aug 2012 12:16
Bax....
I think he means your great limb code for sprites i used for my mode 7 engine?
It repositions the sprites according to the default sprites size.
He only neads to scale the sprites and your function positions them.

Your function is in the usefull functions thread.

Android 2.3 Gingerbread , ZTE Skate , 480x800 , 800 mhz cpu , Samsung Galaxy Y , 240x320 , 832 mhz cpu
Android 4.0 Sandwich , Dmtech 3g 9738B , 1024x768 , 9.7 inches , cortex A8 1.2 cpu , 1 gb ram.
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Aug 2012 12:26
Oh there you go then


this.mess = abs(sin(times#))
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 13:16
yes i need something like that.
i have been searching for it, trying to find it...
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Aug 2012 14:30 Edited at: 1st Aug 2012 14:31
Here it is:


Edit: That's just the rotate function... hang on


this.mess = abs(sin(times#))
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 14:49
i have tried to come up with something simple, even though not very elegant.

it works when all sprites are squares of the same size, but when I ran it on sprites of different sizes, it turned out a mess!!!

baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Aug 2012 15:35
Try something more like this:



this.mess = abs(sin(times#))
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 16:15
BAXSLASH

Thanks a lot it works perfectly!!!!!!!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 1st Aug 2012 16:16 Edited at: 1st Aug 2012 16:17
Glad to help as ever

I think that's my first real attempt at AppGameKit in Tier 2 as well

...and C++ I think...


this.mess = abs(sin(times#))
3d point in space
14
Years of Service
User Offline
Joined: 30th Jun 2009
Location: Idaho
Posted: 1st Aug 2012 16:19 Edited at: 1st Aug 2012 16:21
the rotate about in the project I made works just as good as baxslashes, maybe you like his better though and I got it to animate sprite sizes too. I use things that maybe people don't like.

Developer of Space Chips, pianobasic, zipzapzoom, and vet pinball apps. Developed the tiled map engine seen on the showcase. Veteran for the military.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 16:22
Here is a cleaned up version cos the first version was a mess!!!

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 16:24
and you don't even need a sprite as a main reference point, you can put an XY co-ord and replace this code:

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 1st Aug 2012 23:41
Baxslash, in the end all that was needed was:

spritex = agk::GetSpriteXByOffset(counter) * resizefactor;
spritey = agk::GetSpriteYByOffset(counter) * resizefactor;

I don't know why it was not working before.

Now all works perfectly, I am a step nearer to my goal!
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Aug 2012 10:19
Yes but if you want to scale and keep your "character" in the same place you would want to use a datum


this.mess = abs(sin(times#))
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 2nd Aug 2012 14:08
I used 0,0 as a datum and then added an X & Y offset to the setspriteposition
baxslash
Valued Member
Bronze Codemaster
17
Years of Service
User Offline
Joined: 26th Dec 2006
Location: Duffield
Posted: 2nd Aug 2012 14:08
That works too


this.mess = abs(sin(times#))

Login to post a reply

Server time is: 2024-04-27 14:26:40
Your offset time is: 2024-04-27 14:26:40