Jump to content

sprite locations and functions


dthrasher90
 Share

Recommended Posts

Hey guys, quick question... hopefully.  So I have a sprite in one function with x,y coordinates, I am trying to pass to another function.  Im essentially using this sprites position to align others.  How do you accomplish this?  The only caveat is that function B is located in another file, its just being invoked in functionA.  So Like:

 

 

function A (){

//lots of stuff

game.add.sprite = sprite1(some.x, some.y)

B();

}

 

functionB (){

game.add.sprite= sprite2(sprite1.x, sprite1.y);

}

 

Link to comment
Share on other sites

the js file where you have the function B defined has to be loaded before the other file where you;re using it.


 
/// fileA.js 

function A (){

game.add.sprite = sprite1(some.x, some.y)

B();

}

 
/// fileB.js
function B (){

game.add.sprite= sprite2(sprite1.x, sprite1.y);

}

 

So in your index.html file you just do

<script src="fileB.js"> </script>
<srcipt src="fileA.js"> </script>
Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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