How do I Make a sprite larger as it gets closer?

0 favourites
  • 5 posts
From the Asset Store
2d mushroom sprite 2d game character enmy sprite game art
  • I need a sprite to get bigger as it gets closer to the bottom of the layout, simulating a car driving towards you from the horizon. Sort of a 3d illusion.

    I've tried some stuff, but its clearly wrong lol.

    Every .1 seconds --> set pos to Enemy.y

    pos < Enemy.y --> set size to (Enemy.Width + 1, Enemy.Height + 1)

    This works somewhat, but they don't ever stop growing really, and they grow at a bad rate. Its just not right lol. I'm sure there is a simple way to do this, or some math to apply. Any suggestions?

    Thanks.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Just do something like: Width < LargestSizeYouNeed ==> Width=Width+dt*128 <== adjust this for speed. Height = Width (if it's not square adjust this with a ratio).

  • Yeah, but then they just grow no matter what, not just when they approach the bottom of the layout. Unless im missing something? How do i do this with regard to the Y co-ordinate?

  • If it's non-interactive just add a downward movement of some sort, if not do something like - Every tick: Width = DesiredWidth * Sprite.Y/LowestYItCanGet <== This is then a ratio between the current position and total height. So, for example, if your layout is 640 tall and the car at 640 should be 256 pixels wide and currently it is at 320 or so you do something like: Every tick Width = 256 * Sprite.Y/640 - which will be equal to 0.5, so your car will be 128px wide.

  • Yeah that's what i was going for. Thanks!

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