0 Favourites

Zoom sprite to 100%

  • I could use some guidance on what would be a good method to make a zooming effect. I don't want it to seem like the camera is moving in, but to scale up the size of the sprite. What I'm trying to do is take a sprite resized down to like 2x2 and then on an event have it incrementally scale up to 100% of its original size, and at that point stop scaling.

  • I guess here's a way..

    Give your sprite 2 variables- initwidth and initheight to store the size you want it to scale up to.

    Then make something like

    On conditions met ->

    -sprite.width < sprite.initwidth -> add 1 to sprite.width

    -same for sprite.height

    There should be a better way, but this is first that comes to my head:P

    Hope it helps:)

  • Construct 3

    Buy Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Buy Now Construct 3 users don't see these ads
  • That works well enough for me. I can't believe I didn't think of that. Thank you JJList

  • Anytime! <img src="smileys/smiley2.gif" border="0" align="middle" />

    Glad I could help ^_^

  • How about objects that aren't square? When I use this method it doesn't scale proportionately so the sprite is distorted until it reaches full size. I'm able to counteract the distortion somewhat by playing around with the rate that the x and y scale but my math isn't good enough to make it look completely smooth. Any ideas?

  • Hmm, that's odd.. It was meant to work for non-sqaure sprites..

    Make sure your initwidth != initheight

    Well, I'm probably wrong:P Mind posting your capx?:)

  • My bad, sorry:) Fixed! link

  • JJList Thank you once again, that did the trick :)

  • Burvey re: your capx, if the sprite is not square it will distort. The aspect ratio of width and height cannot increment at the same rate.

    my sprite was 100x60 and grew distorted (flat looking) and then when it approached full size it finally stretched out to normal, but the transition is not what the OP is talking about.

    I'm still looking for the best way to do this.. probably scale? If I find out I will post it here.

  • jobel I was the OP ;)

    Try JJList solution above. It worked well for me.

  • sorry! I meant to link that to JJList

    I download the capx link...

  • this works..

    Hi,

    I don't mean to step on toes but unfortunately Sprite doesn't have a scale expression. So here are the steps to get the effect you want.

    1. Add an instance variable to your sprite, call it "myscale" and give it an initial value of 0.1.

    2. Add an event with the "compare instance variable" condition and set it up as follows:

    Sprite: myscale<1.0
    ---> Sprite: add 1.0*dt to myscale
    ---> Sprite: set scale to myscale

    Note, the first action is the "add to" action under "instance variables" and the 2nd action is "set scale" under "size & position".

    This will need some tweaking to make it happen in one second. As it is now the expression 1.0*dt can be read as 1 per second, but we're going from 0.1 to 1.0 in a second, or just 0.9 in a second. So it should be like this:

    Sprite: myscale<1.0
    ---> Sprite: add 0.9*dt to myscale
    ---> Sprite: set scale to myscale

    Another thing you can deal with if you like is what I like to call over shooting. With this event the end scale will likely be a bit more than 1.0. You can use the min() expression to limit the highest value to 1.0 and set up your event like this:

    Sprite: myscale<1.0
    ---> Sprite: set myscale to min(self.myscale + 0.9*dt, 1.0)
    ---> Sprite: set scale to myscale

    As a final note you can make the duration longer or shorter by tweaking the dt expression.

    half second:

    2*0.9*dt

    two second:

    0.5*0.9*dt

  • You only need one variable and the known aspect ratio if you want to scale them consistently and absolutely and avoid scale.

    If say your object is 16:9 ratio, and you were scaling it to 10x -

    width=Lerp(self.width,self.width*10,0.5)

    height=(width/16)*9

    Or

    height=width*0.5625

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)
Similar Topics Posts Views Last Post
Unread hot topic
0 Favourites
Sprite Font Generator - v3
368 112,377
RetroDaddy's avatar
RetroDaddy
Unread hot topic
59 13,720
holi's avatar
holi
Unread hot topic
86 28,721
St4rDu57's avatar
St4rDu57