How do I create smooth scaling for moving scaling sprites?

1 favourites
  • 2 posts
From the Asset Store
Fully commented source code/event sheet & sprites to create a space shooter game
  • Hey all! I'm just experimenting with a scene and I'd like some help. A few weeks ago, I asked a question if it was possible to create a "psuedo" 3D game like Resident Evil or Alone in the Dark on the Game Boy Color with Construct. Someone was kind enough to provide me with a capx replicating what I was talking about. Basically, I want to make a game that replicates the 3D look of those games by using a 2D sprite and scaling it as it walks around the environment, giving it the illusion of traveling through a 3D space. Hope that makes sense. Here's the original post if anyone is curious.

    creating-a-quot-pseudo-3d-quot-with-quot-prerendered-quot-backgrounds_t178201

    Anyway, can someone take a second to explain how the events tunepunk created are working in this scene? I get the Z order thing he mentions in my original post. I'm trying to replicate tunepunks capx using slightly different code. I'm having trouble understanding some of the logic and math though. I can't get it to scale the way I want it to. I added a keyboard object and attempted to scale based on whether pressing up or down but it's not working right. The scales are clicking into place instead of slowing scaling. They're the right scale size I want the character to be at when furthest and closest to the camera though. I think I need to use some sort of lerp but I can't get the logic correct. Here's the capx and code. Thanks for taking a look at my post! Cheers!

    https://www.dropbox.com/s/i7yn86kqafza8 ... .capx?dl=0

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Are you using LERP like in the example events?

    LERP will smoothy scale/move/angle things based on the way it is used.

    If you wanted to resize something smoothy, you could use something like;

    (Let's assume your sprite is 100px wide)

    [EVERY TICK]

    --- Set width of Sprite to lerp(sprite.width,desired.width,amount)

    ***Sprite.Width will be the current width of the sprite (in this case 100)

    ***The desired width would be something greater than 100, say 200

    ***The amount is a number between 0 and 1.

    So your action would look actually like; lerp(sprite.width,200,0.5)

    The way lerp "amount" works is imagine 0 is the starting point and 1 is the end point. If you wanted to resize your object by half of the original width to the desired width (in our exmaple here we are using 100 and 200 - but you wanted it to be 150) the amount to lerp by would be 0.5.

    If you apply lerp "every tick" it would do the lerp "amount" every tick... so in the first tick if you used 0.5 your sprite would go from 100 to 150, and the next tick it would go from 150 to 175 (because theres 50px left to 200, so it does half of that again).

    Once lerp gets "close enough" it will snap to the final point (but it has to be VERY close on the float value - several thousandths of one pixel away).

    I hope this explains a bit better how the "smoothness" works.

    ~Sol

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)