简体   繁体   中英

as3 game works with air for android but no in flash player

I made a very simple catching game in flash. The thing is that when I select Air for Android (I've tried with versions 3.2, 3.9 and 4.0) as target publish everything works well. But if I change it to Flash player 10 or 11 it starts "missing" some catches. Any ideas? Here is my code, it just adds come "ball" movieclips from library and drop them in the stage. There is a movieclip that moves with the mouse and catches them.

import flash.events.Event;

var intervaloPelotas = setInterval(addBall, 1000);

var pelotas:Array = [];

var points:Number = 0;

function addBall(){
    var b:Ball = new Ball();
    b.x = Math.ceil(Math.random()*500);
    b.y = -50;
    addChild(b);
    pelotas.push(b);
    b.addEventListener(Event.ENTER_FRAME, dropBall);
}

function dropBall(e:Event){
    var b:Ball = Ball(e.target);
    b.y += 10;
    if(b.y > 400){
        eliminarPelota(b);
    }
}

stage.addEventListener(Event.ENTER_FRAME, mueveHeroe);

function mueveHeroe(e:Event){
    heroe.x = mouseX;
    for(var i:int=0; i<pelotas.length; i++){
        if(heroe.hitTestObject(pelotas[i])){
            eliminarPelota(pelotas[i]);
            //Sumar un punto
            points++;
            puntosTxt.text = String(points);
        }
    }
}

function eliminarPelota(p){
    p.removeEventListener(Event.ENTER_FRAME, dropBall);
    removeChild(p);
}

I had a lot of problems myself developing for android and flash. But then I switch to AIR 13 and it seemed to fix everything without the need to change any of my code.

Try it out, AIR 13 is still in beta but it seems to be the best for android & flash. http://labs.adobe.com/downloads/air.html

I would argue that flash player in browser is unable to do the same level of optimizations that AIR is able to perform by using the GPU. At least I would like to think that is the case.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM