1. Add simple objects
When we enter this class, we can find that there are many ways to create and remove objects. to simulate the physical effect, we first try to add some objects to the engine for simulation. Common particles such as circles and squares
Let's take a look at some simple demos below:
Package {<br/> Import COM. fileitup. fisixengine. core. *; <br/> Import COM. fileitup. fisixengine. participant. circleparticle; </P> <p> Import flash. display. sprite; <br/> public class example3 extends sprite <br/> {<br/> private var myengine: fisixengine; <br/> private var fixobject: fisixobject; <br/> Public Function example3 () <br/>{< br/> Init (); <br/>}</P> <p> private function Init (): void <br/>{< br/> myengine = new fisixengine (); <br/> fixobject = myengine. newfisixobject (); // create a fisixobject <br/> var partic: circleparticle = fixobject. newcircleparticle (50, 50, 50); // Add a circle with a radius of 50 </P> <p> myengine. setgravity (); // set the direction of gravity <br/> myengine. setrender (true); // rendering <br/> myengine. setrendergraphics (graphics); <br/> myengine. startengine (); // start rendering <br/>}< br/>
Step 1: import the library we need
Import com. fileitup. fisixengine. Core. *; <br/> Import com. fileitup. fisixengine. participant. circleparticle; </P> <p> Import flash. display. Sprite;
We don't use many class libraries. We only use two core classes and one particle class.
Step 2: program entry
Myengine = new fisixengine ();
Step 3: Create a fisixobject object and introduce a fisixobject object to the engine through myengine.
Fixobject = myengine. newfisixobject (); // create a fisixobject
Step 4: Create a circle
VaR partic: circleparticle = fixobject. newcircleparticle (50, 50); // Add a circle with a radius of 50 and coordinates (50, 50)
Step 5: render and start the engine
Myengine. setgravity (); // you can specify the direction of gravity.
Myengine. setrender (true); // Rendering
Myengine. setrendergraphics (graphics );
Myengine. startengine (); // start the engine
Effect: A simple ball is running.
Note: (the development platform is Flex + fisixengine. SWC)
2. Add a surface
We add a surface on the basis of the original, that is to say, we need to add a barrier for the circle we are sliding down.
VaR surface: surface = fixobject. newsurface (new vector (0,200), new vector (500,300), 50); // Add a surface
Code List: add only one line of code
Package {<br/> Import COM. fileitup. fisixengine. core. *; <br/> Import COM. fileitup. fisixengine. participant. circleparticle; <br/> Import COM. fileitup. fisixengine. primitives. surface; </P> <p> Import flash. display. sprite; <br/> [SWF (width = '000000', Height = '000000', backgroundcolor = '0xffffff', framerate = '30')] <br/> public class example3 extends sprite <br/>{< br/> private var myengine: fisixengine; <br/> private var fixobject: fisixobject; <br/> Public Function example3 () <br/>{< br/> Init (); <br/>}</P> <p> private function Init (): void <br/>{< br/> myengine = new fisixengine (); <br/> fixobject = myengine. newfisixobject (); // create a fisixobject <br/> var partic: circleparticle = fixobject. newcircleparticle (50, 50, 50); // Add a circle with a radius of 50 <br/> var surface: surface = fixobject. newsurface (new vector (0,200), new vector (500,300), 50); // Add a surface </P> <p> myengine. setgravity (); // set the direction of gravity <br/> myengine. setrender (true); // rendering <br/> myengine. setrendergraphics (graphics); <br/> myengine. startengine (); // start rendering <br/>}< br/>
A simple result is displayed.