Search code examples
androidactionscript-3air

Drawing smoother pixel trails with as3


I am trying to make a slice effect when user moves his fingers on the screen on Android Device like in Fruit Ninja I have a movieClip named Particle which has a circle I tried following

stage.addEventListener(MouseEvent.MOUSE_DOWN , stratSlice);
stage.addEventListener(MouseEvent.MOUSE_UP , endSlice); 
function startSlice(e:MouseEvent):void
{
     stage.addEventListener(MouseEvent.MOUSE_MOVE , drawSlice);
}
function endSlice(e:MouseEvent):void
{
     stage.addEventListener(MouseEvent.MOUSE_MOVE , drawSlice);
}
function drawSlice(e:MouseEvent):void
{
    var p:Particle = new Particle();
    addChild(p);
    p.x = mouseX;
    p.y = mouseY;
}

but when I run it The slice is broken I want it to be seamless.


Solution

  • Adding e.updateafterevent() in the mouse move handler might improve performance a bit.

    In general your code will probably not work as well as other particle effects you see in games such as fruits ninja. For good results you will need to use a particle engine such as

    StarDust: https://code.google.com/p/stardust-particle-engine/

    Flint: http://flintparticles.org/

    Partigen: http://www.desuade.com/partigen/engine

    Starling Particle: https://github.com/PrimaryFeather/Starling-Extension-Particle-System

    I know starling works great on android, not sure about the others