Jump to content

sprite map positioning


Recommended Posts

hello, i have a map laid out that fills the entire screen. i understand how to add a sprite on the map and give it coordinates,

                       var thumb = game.add.sprite( 100, 100 , "levelthumb");

but i wanted to know if the following was possible. can i add lets say 15 of the same sprite on the map giving each one specific coordinates. i know this can be done easily with a for loop and passing in random x and y just like this exmaples http://phaser.io/examples/v2/groups/add-a-sprite-to-group... but i want to give them specific coordinates for each one.  


Link to comment
Share on other sites

Yeah, its possible to do that. Just write a function that will pass the x and y coordinates as parameters.

function create() {

    lumpofsprites = game.add.group();
    lumpofenemies = game.add.group();

    function spritepositioning(x, y){ //pass in x&y coordinates when calling this
    lumpofenemies.create(x, y, 'IMAGENAMEHERE'); //enter image name here or set it as a parameter
    var theplayer = game.add.sprite(300, 240, 'IMGNAMEHERE');



Link to comment
Share on other sites


  • Recently Browsing   0 members

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