Group

You can group together multiple different objects and are not limited by choosing only similarly-shaped or coloured objects. To initialize a group which has been placed on the game map, like in the image below,

html5_tutorial_mightyeditor_spritegroup

 

Simply go to the source editor and add this line in the state you are using:

"use strict";
"use strict";
window.SpriteGroup.state.menu = {
	create: function(){		
		//use mt.create here, for example
		this.smile=mt.create("smile");
		//this.smile.mt.children.character accesses the desired group object
		this.smile.mt.children.character.animations.add("run", [6,7,8,9,10,11], 10, true);
		this.smile.mt.children.character.animations.play("run");
		
		//this.smile.self accesses the whole group object
		//in this case, changing the alpha level of the whole group
		this.smile.alpha=0.5;		
	},
	
	update: function(){
		
	}
};

After creating the group, individual group members can be accessed by usingĀ this.group_name.mt.children.object_name.

Sample is available here.

Leave a Reply

Your email address will not be published. Required fields are marked *