Search the Community
Showing results for tags 'roam'.
Found 2 results
So I have 3 different characters (using the same sprite at the moment). They are supposed to roam given a predefined path for each. I am using 3 different loops so that they start at different times. I don't want them to start and stop at the same time. Trying to make it as natural as possible and so far I got this http://jsfiddle.net/Batzi/abs191e5/250/ Can someone suggest improvements? I need to make it look as smooth and natural as possible.
So I have this demo below before I explain what I am trying to do http://jsfiddle.net/Batzi/abs191e5/19/ So I am using the function 'moveToXY()' to move my character. Every 5 seconds it's moving towards a different direction. I am using SetTimeout() as you can see in the code. All animations are applied so everything is working as intended. In the update(), I am specifying when the character should stop (ex: if it reaches a specific x & y). However, I want to declare a predefined path such as this one var path = [[1700, 800], [1600, 800], [2300, 800]];and have my character roam around but I don't want to duplicate the setTimeout. How would you approach this problem? PS: Ignore the coordinates in path. They're out of proportions.