Jump to content

how to call prefab function ?


am0314
 Share

Recommended Posts

i have a prefab , code like this

function dicehistory(aGame, aParent, aName, aAddToStage, aEnableBody, aPhysicsBodyType) {
	
	Phaser.Group.call(this, aGame, aParent, aName, aAddToStage, aEnableBody, aPhysicsBodyType);
	var _record_dice_ = this.game.add.sprite(0.0, 0.0, 'record_dice_001', null, this);
	_record_dice_.scale.setTo(0.4, 0.4);
	
	var _record_dice_1 = this.game.add.sprite(0.0, 30.0, 'record_dice_002', null, this);
	_record_dice_1.scale.setTo(0.4, 0.4);
	
	var _record_dice_2 = this.game.add.sprite(0.0, 60.0, 'record_dice_001', null, this);
	_record_dice_2.scale.setTo(0.4, 0.4);
	
	var _text = this.game.add.text(-2.0, 95.0, '17', {"font":"bold 20px Arial","fill":"#ff0000"}, this);
	_text.scale.setTo(1.7, 1.7);
	
	var _hall_rednb_ = this.game.add.sprite(-2.0, 134.0, 'hall_rednb_011', null, this);
	_hall_rednb_.scale.setTo(1.2, 1.2);
	
	function ChangeState(a,b,c){
		this._record_dice_.loadTexture('record_dice_00'+a);
		this._record_dice_1.loadTexture('record_dice_00'+a);
		this._record_dice_2.loadTexture('record_dice_00'+a);
	}
}

i add use this prefab in other prefab 

function tableobject(aGame, aParent, aName, aAddToStage, aEnableBody, aPhysicsBodyType) {
	
	Phaser.Group.call(this, aGame, aParent, aName, aAddToStage, aEnableBody, aPhysicsBodyType);
	var _table_ = new table_s1(this.game, 0.0, 0.0);
	this.add(_table_);
	
	var _group1 = new dicehistory(this.game, this);
	_group1.position.setTo(157.0, 122.0);
	
	var _group2 = new dicehistory(this.game, this);
	_group2.position.setTo(195.0, 122.0);
	
}

how to in tableobject call dicehistory.ChangeState(a,b,c) ?

or other way to do this?

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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