Animating element to move up in html5/javascript canvas -


I am making simple animations in the JavaScript HTML canvas. Currently I have a function that infront the element infinitely below. I want to go inverted and infinitely (start from the lower part of the page and go up and up and up), but all my efforts and experiments have failed.
I would be grateful for any thoughts!

This is the function I have, which moves the element down:

  function slidedown () {start + = 1; Var m = document.getElementById ('money'); M.style.top = start + "px"; M.style.left = "300px"; } Var start = 350; Function Rain () {var m = document.createElement ('img'); MID = "money"; M.src = "images / hollywood"; M.style.position = "full"; M.style.top = start + "px"; // m.style.top = "0px"; M.style.left = "300px"; M.setAttribute ("class", "wealth"); Document.body.appendChild (m); set interval (movement, 500);}  

how do i Can I go up?

I'm not sure what to do with canvas, but you

Invert the initial edge to subtract

  function layout () {s Tart--; /// above 1 pixel style. Top = "+" px "; } Var start = 350; Var m = document.getElementById ('money'); /// cache here var style = m.style; /// cache style style Left = "300px"; The performance of caching will improve as it increases communication between JS and DOM. 

However, as a tip: When the elements have gone out of sight, you want to stop the loop otherwise you will apply unnecessary code so that there is a condition to add a condition to prevent Rob. Go.


Comments

Popular posts from this blog

ios - How do I use CFArrayRef in Swift? -

eclipse plugin - Run java code error: Workspace is closed -

c - Error on building source code in VC 6 -