I have a dice game where on both client sides should execute the same code.
For example this function:
Code: Select all
this.sfs.send(new SFS2X.Requests.System.ExtensionRequest(DICE_GAME.GAME_COMMANDS.GET_MYRAND_NR));
this.myRandF = function(evt)
{
/**GET DATA VOM SERVER **/
var first = evt.params.myRand[0];
var sec = evt.params.myRand[1];
var third = evt.params.myRand[2];
var value = Math.floor(Math.random()* this.cubes1to20_arr.length);
var cube = this.cubes1to20_arr[value];
var if6 = cube.image.value;
/** SETTING POSTIONS FOR THE CUBE **/
var x = selbst.WB.x + selbst.WB.image.width;
var y = selbst.WB.y + selbst.WB.image.height/2;
//selbst.cubeToDelete = cube;
/**CREATING TWEEN MOTION FOR MYRAND **/
createjs.Tween.get(this.myrand).to({x:first},500).to({x:sec},500).to({x:third},500).to({x:cube.x},500);
var myTween = createjs.Tween.get(cube).wait(2600).to({scaleX:0,scaleY:0,alpha:0},300, createjs.Ease.bounceOut).call(this.if_ready,[if6]);
myTween.wait(200).set({alpha:1,x:x,y:y,scaleX:1,scaleY:1},cube);
};
this.sfs.addEventListener(SFS2X.SFSEvent.EXTENSION_RESPONSE,this.myRandF,this);
The tween motion is executed in the event listener's function so it should be seen by both of the clients but this only works on for one client.
How can I get this to be executed for both of the clients? My ideea was to call this motion function in the event listener' s function but if I am wrong what are other possibilities ?
Thank you in advance for your help