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

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

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