Panel animation movement
-
@Matt_SF Ok thanks.
Will try the snippet in a bit. -
@Matt_SF Man it works!!!
Will compare the code and give feedback on where I messed up. Thanks so much man!! -
-
@Matt_SF Hello man.
Thanks again for the snippet.
Trying to figure out how and why you got it right and what was missing on my side. I tried iterating through your code to understand it, but I'm still not getting it.const var pnlAni = Content.getComponent("pnlAni"); const var Panel1 = Content.getComponent("Panel1"); pnlAni.setPosition(0, 0, 50, 50); pnlAni.setTimerCallback(function() { var posY = pnlAni.get("y"); if (posY == 0) posY++; else if (posY == 177) posY--; pnlAni.setPosition(0,posY , 50, 50); this.repaint(); });
This is what I created based on your working snippet. It's not working and I'm not understanding why. Based on my logic, I think this code is right (which is totally not), and I want to understand why I think this is. What am I missing here?
-
@Sawer look at your code:
if posY == 0 -- do something...
if posY == 177 do something...So assuming posY == 0 the first time, what happens then? and what does posY ==?
-
@Lindon It does nothing. Because is neither equal to 0 or 177. True, thanks..
-
@Sawer said in Panel animation movement:
@Lindon It does nothing. Because is neither equal to 0 or 177. True, thanks..
correct so try this:
var summingValue = -1; pnlAni.setTimerCallback(function() { var posY = pnlAni.get("y"); if (posY == 0) summingValue = 1; if (posY == 177) summingValue = -1; posY = posY + summingValue; pnlAni.setPosition(0,posY , 50, 50); this.repaint(); });
-
@Lindon I would never have thought of doing it like this. Nice
-
@Lindon Thanks so much for the explanation and the new code!