Flash物理引擎演示效果:
2009-03-02 18:13
423 查看
/Files/hero82748274/Example.swf
实现代码:
package
{
import com.fileitup.fisixengine.constraints.SpringConstraint;
import com.fileitup.fisixengine.core.FisixEngine;
import com.fileitup.fisixengine.core.FisixObject;
import com.fileitup.fisixengine.utils.BoundingBox;
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
/**In this example, a jello-type object is created and manipulated by the mouse
*/
[SWF(width='700',height='500',backgroundColor='0x50464b',frameRate='30')]
[Embed (source="1.jpg")]
public class Example2 extends MovieClip{
private var myEngine:FisixEngine
private var txtFPS:TextField
public function Example2 (){
//first, create an instance of the fisixengine object
myEngine = new FisixEngine()
//bound all of the objects in the simulation within a box
myEngine.setBounds(new BoundingBox(0,0,700,500))
//enable collisions with the bounding box
myEngine.boundsCollisions=true
//set the gravity to pull down at a rate of 1 pixel per second
myEngine.setGravity(0,1)
//create a jello cube
var jello:FisixObject = myEngine.newFisixObject();
for(var i:uint=0;i<12;i++)
jello.newCircleParticle(250+100*Math.cos(i*30),200+100*Math.sin(i*30),20);
SpringConstraint.constraintAll(jello,jello.particles,.9);
//attach the corner of the jello to the mouse
myEngine.newMouseAttacher(jello.particles[0],root,3)
//turn on primitive rendering
myEngine.setRender(true);
//tell the engine where to render to
myEngine.setRenderGraphics(graphics)
addEventListener(Event.ENTER_FRAME,onEnterFrame)
txtFPS = new TextField()
addChild(txtFPS)
}
private function onEnterFrame(e:Event):void{
myEngine.mainLoop(1)
txtFPS.text = int(myEngine.getRealFPS()).toString()
}
}
}
实现代码:
package
{
import com.fileitup.fisixengine.constraints.SpringConstraint;
import com.fileitup.fisixengine.core.FisixEngine;
import com.fileitup.fisixengine.core.FisixObject;
import com.fileitup.fisixengine.utils.BoundingBox;
import flash.display.Bitmap;
import flash.display.MovieClip;
import flash.events.Event;
import flash.text.TextField;
/**In this example, a jello-type object is created and manipulated by the mouse
*/
[SWF(width='700',height='500',backgroundColor='0x50464b',frameRate='30')]
[Embed (source="1.jpg")]
public class Example2 extends MovieClip{
private var myEngine:FisixEngine
private var txtFPS:TextField
public function Example2 (){
//first, create an instance of the fisixengine object
myEngine = new FisixEngine()
//bound all of the objects in the simulation within a box
myEngine.setBounds(new BoundingBox(0,0,700,500))
//enable collisions with the bounding box
myEngine.boundsCollisions=true
//set the gravity to pull down at a rate of 1 pixel per second
myEngine.setGravity(0,1)
//create a jello cube
var jello:FisixObject = myEngine.newFisixObject();
for(var i:uint=0;i<12;i++)
jello.newCircleParticle(250+100*Math.cos(i*30),200+100*Math.sin(i*30),20);
SpringConstraint.constraintAll(jello,jello.particles,.9);
//attach the corner of the jello to the mouse
myEngine.newMouseAttacher(jello.particles[0],root,3)
//turn on primitive rendering
myEngine.setRender(true);
//tell the engine where to render to
myEngine.setRenderGraphics(graphics)
addEventListener(Event.ENTER_FRAME,onEnterFrame)
txtFPS = new TextField()
addChild(txtFPS)
}
private function onEnterFrame(e:Event):void{
myEngine.mainLoop(1)
txtFPS.text = int(myEngine.getRealFPS()).toString()
}
}
}
相关文章推荐
- Flash飞行游戏物理引擎
- 使用jbox2d物理引擎打造摩拜单车贴纸动画效果
- 所有的物理引擎演示程序
- box2dflash flash物理引擎
- flash与物理引擎:创建碰撞墙
- android游戏引擎andengine学习系列六:Physics物理碰撞效果理解
- js+flash实现的5图变换效果广告代码(附演示与demo源码下载)
- Unity2D游戏物理引擎演示
- flash物理引擎应用:你的第一个Fisix应用程序
- 游戏引擎剖析 (5) 物理,运动,效果
- flash与物理引擎:拖拽
- flash物理引擎应用:你的第一个Fisix应用程序
- IOS UIDynamic仿物理引擎-浮动碰撞效果
- Atitit 游戏引擎---物理系统(1)------爆炸效果
- flash与物理引擎:贴图
- flash物理引擎应用:你的第一个Fisix应用程序
- android游戏引擎andengine学习系列六:Physics物理碰撞效果理解
- Flash 物理引擎的未来
- flash物理引擎应用:创建粒子
- flash物理引擎应用:Fisix应用程序核心类