Posted by Sankar.G | Posted in APE Engine | Posted on 4:31 PM
package {
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp);
rp.setFill(0x666666);
rp.setLine(0, 0xff0000, 1);
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
wp = new WheelParticle(280,10,25,false,10,0.3,0.1,1);
defaultGroup.addParticle(wp);
wp.setFill(0xff0000);
wp.setLine(0,0xff0000,0);
wp.sprite.addEventListener(MouseEvent.MOUSE_DOWN,down);
wp.sprite.addEventListener(MouseEvent.MOUSE_UP,up);
APEngine.addGroup(defaultGroup);
function down(d1:Event):void
{
removeEventListener(Event.ENTER_FRAME,run);
wp.sprite.startDrag();
}
function up(d2:Event):void
{
wp.px=wp.sprite.x;
wp.py=wp.sprite.y;
stopDrag();
addEventListener(Event.ENTER_FRAME, run);
}
function run(evt:Event):void
{
APEngine.step();
APEngine.paint();
}
}
}
}
Examples:
APE with out Drag.swf
import flash.events.Event;
import flash.events.MouseEvent;
import flash.display.Sprite;
import org.cove.ape.*;
public class Test extends Sprite
{
private var wp:WheelParticle;
public function Test():void
{
stage.frameRate = 20;
addEventListener(Event.ENTER_FRAME, run);
APEngine.init(2/4);
APEngine.container = this;
var defaultGroup:Group = new Group();
defaultGroup.collideInternal = true;
APEngine.addMasslessForce(new Vector(0,2));
var rp:RectangleParticle = new RectangleParticle(250,300,200,10,0.52,true);
defaultGroup.addParticle(rp);
rp.setFill(0x666666);
rp.setLine(0, 0xff0000, 1);
var rp1:RectangleParticle=new RectangleParticle(490,300,200,10,-0.52,true);
defaultGroup.addParticle(rp1);
rp1.setFill(0xff0000);
rp1.setLine(0,0x666666,1);
var rp2:RectangleParticle=new RectangleParticle(430,450,200,10,0,true);
defaultGroup.addParticle(rp2);
rp2.setFill(0xff0000);
rp2.setLine(0,0x666666,1);
wp = new WheelParticle(280,10,25,false,10,0.3,0.1,1);
defaultGroup.addParticle(wp);
wp.setFill(0xff0000);
wp.setLine(0,0xff0000,0);
wp.sprite.addEventListener(MouseEvent.MOUSE_DOWN,down);
wp.sprite.addEventListener(MouseEvent.MOUSE_UP,up);
APEngine.addGroup(defaultGroup);
function down(d1:Event):void
{
removeEventListener(Event.ENTER_FRAME,run);
wp.sprite.startDrag();
}
function up(d2:Event):void
{
wp.px=wp.sprite.x;
wp.py=wp.sprite.y;
stopDrag();
addEventListener(Event.ENTER_FRAME, run);
}
function run(evt:Event):void
{
APEngine.step();
APEngine.paint();
}
}
}
}
Examples:
APE with out Drag.swf
Comments (0)
Post a Comment