I've been trying to work out how to half the size of a sprite and then return it back to its' original size using lerp.
I've managed to get the sprite to increase and decrease in size using lerp. However, it doesn't seem to be increasing/decreasing by the right amount. It's probably some bad maths on my part, or just a wrong use of lerp ^^. Any help would be muchly appreciated.
Thanks for reading :)
It's hard to tell without looking at a .capx - but have you tried something like floor(lerp(Self.width,Self.Width*2,dt*self.scrollspeed)) - not 100% sure of the syntax - but using floor will force integers rather than fractions, which is what could be messing up your sizes perhaps.
This isn't the full capx as I've got a fair bit of work in it, but it's got the same events etc... for controlling the size of a sprite.
I tried your suggestion, but unfortunately it didn't work. Thanks for the help though! :D
lerp is mostly used to animate over time, and as you use a trigger once, it don't work right here.
2 solutions :
Thanks a bunch for the help, Guizmus! Worked a charm :). I used trigger once to stop the size constantly increasing, but using the two variables you added has solved that :D.
If I finish this project I'll be sure to give you a shout out for your help :)
No problem :)
I didn't optimize it though, as it was just a sample. If you add this on a lot of objects, be sure to use the scale instead (scale = height/width) with th same trick, initialScale being then a variable on your button. Less variables = better :D
Will do, thanks for the tip :D!
Develop games in your browser. Powerful, performant & highly capable.
Guizmus - awesome capx, very useful, thanks a lot.
Toby12 - thanks for posting my exact question and getting it answered. I was just having this problem.