Monday, May 24, 2010

Um Nick in place of the current code regarding the multiple players etc try this instead. I have no idea if its going to work or not. Ill be in the games lab today if you want me to give you my copy.

function codeStuff():void {
ExternalInterface.addCallback("bubblepop",bubblepop);
}

var objs:Array;
var pt:Point = new Point();

function bubblepop (posx:int,posy:int, player:int):void {
pt.x = posx; pt.y = posy;
objs = stage.getObjectsUnderPoint(pt).reverse();
for each (var obj:Object in objs) {
if (obj is InteractiveObject && obj.mouseEnabled) {
pt = obj.globalToLocal(pt);
obj.dispatchEvent(new MouseEvent(MouseEvent.CLICK,true,false,pt.x,pt.y));
break;
}
}
if(player == 0) {
thisBall.addEventListener(MouseEvent.CLICK, thisBallClickHandler);
thisBall2.addEventListener(MouseEvent.CLICK, thisBallClickHandler);
thisBall3.addEventListener(MouseEvent.CLICK, thisBallClickHandler);
thisBall4.addEventListener(MouseEvent.CLICK, thisBallClickHandler);
thisBall5.addEventListener(MouseEvent.CLICK, thisBallClickHandler);
thisBall6.addEventListener(MouseEvent.CLICK, thisBallClickHandler);
}

if(player == 1) {
thisBall.addEventListener(MouseEvent.CLICK, thisBallClickHandler2);
thisBall2.addEventListener(MouseEvent.CLICK, thisBallClickHandler2);
thisBall3.addEventListener(MouseEvent.CLICK, thisBallClickHandler2);
thisBall4.addEventListener(MouseEvent.CLICK, thisBallClickHandler2);
thisBall5.addEventListener(MouseEvent.CLICK, thisBallClickHandler2);
thisBall6.addEventListener(MouseEvent.CLICK, thisBallClickHandler2);
}
}

P.S. if we cant get it to work my simple idea would be two have two different coloured objects (eg red and blue) and player 1 must hit red and player 2 must hit blue because all this code is confusing :P

No comments:

Post a Comment