I'm creating a RPG and would like to add all of my sprites to a spriteContainer, and NPCs to a npcContainer, etc... The reason being is so I can simply add the container and their associated labels to the stage instead of each individual sprite.
I would be using the create js container
object.
I want to set an initial x,y
for the container, but then set each element in the container to a different x,y
with their labels. Should I just not use a container? What is the reason for containers?
Thanks
Edit: I call addNPCs at the beginning which creates a bunch of stuff then adds them to a container:
function addNPCs() {
var NPCs = [];
spriteContainer = new createjs.Container();
spriteContainer.x = spriteContainerX-camX;
spriteContainer.y = spriteContainerY-camY;
spriteBMP = new createjs.Bitmap("myBmp.png");
spriteBMP2 = new createjs.Bitmap("myBmp.png");
spriteBMP3 = new createjs.Bitmap("myBmp.png");
spriteLabel = new createjs.Text("Hey kitty! Come talk to me!", "14px Arial", "white");
spriteLabel.y = -70;
NPCs.push(spriteBMP, spriteBMP2, spriteBMP3);
for (npcs in NPCs) {
spriteContainer.addChild(npcs);
console.log("added " + npcs);
}
}
Then add that container:
stage.addChild(spriteContainer);