Jump to content

Using var from other function in 'update'


micouy
 Share

Recommended Posts

Hi, it's my first time here and my first game. I don't know much about javascript also.

My problem is that I set a variable 'rockUp' to create sprite in my function addRocks and I want to use x of this sprite in 'update' to add points. Function addRocks is called by a looped timer set in 'create', so it can't detect x of that sprite correctly.

What do I have to do?

code: drive.google.com/file/d/0B2GJjU5fsrlgZEV3Y2F2dTJEelk/view

(sorry for my english)

Link to comment
Share on other sites

You can create an array to store your rocks, you put them inside of the array from the addRocks() function and then in the update method you get the x for each rock you have.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...