javascript - Phaser sprite map positioning -
i have map laid out fills entire screen. understand how add sprite on map , give coordinates,
var thumb = game.add.sprite( 100, 100 , "levelthumb");
but wanted know if following possible. can add lets 15 of same sprite on map giving each 1 specific coordinates.
i know can done loop , passing in random x , y exmaples http://phaser.io/examples/v2/groups/add-a-sprite-to-group want give them specific coordinates each one.
for wonder how solved helped me it.
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 parameter }
spritepositioning(100,400); spritepositioning(0,400); spritepositioning(500,100); spritepositioning(424,432); spritepositioning(216,200); spritepositioning(500,578); var theplayer = game.add.sprite(300, 240, 'imgnamehere'); lumpofsprites.add(theplayer);
}
Comments
Post a Comment