Create incredible particle effects with Partigen 2
Do you remember Partigen?
Andrew Fitzgerald from Desuade released the new version, of his amazing particle effects engine: Partigen 2.
Featuring over 120 exclusive preset effects, Partigen 2 is the first and only extension for Flash that let’s you to create complex particle effects in just a click.
The list of features is huge, so I am listing the ones I found most interesting:
- Full Package XML-Serialization
- Fully documented AS3 API
- Emitters can be created with either the IDE component or via ActionScript
- Particles can be any display object that inherits the Particle class
- Renderers can be shared across multiple Emitters
- Pools can handle the internal creation and storage of Particle objects in memory
You can read the full list of features here
The documentation is awesome, the best I’ve seen so far in a product like this one. You can access the full API documentation, and from this link you can access a 42 minutes long video covering the entire Partigen 2 component, and you can create beautiful effects using the component in less than a minute.
Anyway, we’re not here to talk about the component, but to test the AS3 API. Read more
Box2D tutorial for the absolute beginners – revamped
About a year ago I published a Box2D tutorial for the absolute beginners.
With 2.1 release, a lot of things changed, so it’s time to publish another tutorial for the absolute beginners.
In this tutorial we’ll cover needed libraries to import, world creation, debug draw and the creation of static and dynamic boxes and circles. And obviously the simulation itself
This is the movie we are going to make:
And this is the script used to do it: Read more
Box2DFlash 2.1a released – what changed
Some days ago Boris the Brave released the new version of the popular physics library.
There are some critical changes that won’t make old projects run in the new environment.
The most important ones are:
- It is now not necessary to specify a size for your world, it’ll always be large enough.
- Improved collisions system
- You must specify if a body is dynamic, no matter if its mass is greater than zero
- Fixtures now determine material properties of shapes, such as density, friction and so on
But I think an example will be more explicative than a thousand words, so I created a simple vehicle you can control with left and right arrow keys. It uses revolute joints and motors.
This is the code you would need in the old Box2D version Read more
Way of an Idea Box2D prototype – Step 3
Welcome to the 3rd part. In part 2 we allowed the player to draw the chalk track in a “paused” Box2D environment and then run the simulation.
Now it’s time to delete our chalk track.
A bit of theory: although the simulation is paused, the chalk bodies are already placed in the Box2D world. So we can easily select them with our old friend GetBodyAtMouse function.
Then we need to know whether the selected body is a chalk or not… we don’t want to delete other level assets or even the ball!!
So we must check if the userData of the selected body (that is the attached sprite) is a chalk. If true, we can remove the sprite from the stage and destroy the body.
This is the code: Read more
Shrink it Box2D prototype – Step 2
In the previous step I showed you how to shrink/expand any kind of polygon.
Anyway in the original game, you can’t expand objects as much as you want, because you need mass to do it, and this adds strategy to the gameplay, because you have to shrink objects to gather the necessary mass to expand other ones.
I suppose the required amount of mass is the difference between the final and the initial mass.
At the same time, when we shrink an object, we’ll gather mass… probably determined by the difference between the initial and the final mass.
When you want to play with masses, the first thing you must setup carefully is the expand/shrink ratio. In the previous step I used a 10% for both shrinking and expanding.
This leads to a glitchy gameplay because if I have a sphere with a radius = 100 and I shrink it by 10% I get a sphere with a radius = 90. But if I expand 90 by 10% I get a sphere with a radius = 99. I don’t get the original sphere. So I cannot use these values, because I need to get the initial object if I expand it and then shrink it or if I shrink it and then expand it.
So in this example I am using 20% shrinking and 25% expanding. This way, our object with radius = 100 shrinked by 20% will have a radius of 80… and a radius = 80 expanded by 25% returns 100 again.
It’s up to you to find a couple of compatible numbers.
About masses, this is the concept: when the player shrinks an object, there isn’t any problem, I just have to compare the old mass with the new one and add the difference to the available mass. To get a body’s mass, use GetMass().
When the player tries to expand an objects, things become a little harder because we can’t know the future mass of the body, unless we want to heavily play with geometry.
So we have to make a little trick: first we remove the original shape, then we create and attach the new, expanded shape to the body, so we can get the mass of the final body. If we have enough mass, then we render the body, otherwise we remove the new shape and restore the old one. Since we do everything before rendering the frame, it will work nicely.
This is the script: Read more
Way of an Idea Box2D prototype – Step 2
It’s time to apply the concepts seen at Pausing a Box2D simulation with Way of an Idea Box2D prototype to create a paused Box2D simulation that will start only when you’ll press SPACE, and meanwhile you can draw paths, just like in the original game.
The only problem with this technique is you can’t use the debug draw to test your projects, because debug draw draws only after Step function has been executed, and since the game starts with the simulation paused, you can’t see the Box2D boxes you are drawing (and you can’t even see other assets too) until you start the simulation.
So the trick is: placing the Box2D boxes, the ones debug draw won’t draw, and attaching the movieclips to them. The movieclips will be rendered because I am adding them to stage, and they will remain in position until the simulation starts.
So the script becomes: Read more
Pausing a Box2D simulation
There is a Box2D feature easy to implement and capable to add interesting gameplay that I haven’t found explained anywhere: the pause.
I want to stop a Box2D simulation when I click the mouse, and to play it again with another click.
The core function of this feature is Step.
Normally is called this way:
b2World.Step(timestep, iterations)
where timestep is the amount of time to simulate (normally 1/30 or 1/60 seconds) and iterations the number of iterations to be used by the constraint solver.
So, playing with timestep is the key to success. In this script, copied/pasted from A smart way to manage sleeping objects with Box2D I am going to stop the simulation with a mouse click, and let it play again with another mouse click. Read more
Shrink it Box2D prototype
Finally the Shrink it prototype is ready.
This post continues Scaling objects with Box2D and Scaling objects with Box2D – part 2, with these features:
1) You can’t modify static objects
2) You can shrink objects with left mouse button, and expand them with left mouse button + SPACE, as in the original game
3) You can shrink/expand any polygon thanks to Ilya’s suggestion made in this post.
Now in the stage we have four objects: a circle, a square, a triangle and a custom shape. Refer to Understanding custom polygons in Box2D for more information about custom shapes. Read more
Way of an Idea Box2D prototype
Did you enjoy Way of an Idea?
Nice physics game… besides the joints and motors used in level design, the most interesting part is the chalk drawing.
We are going to do it in three steps
Step 1 – Freehand drawing
Let’s start with a simple script with some mouse listeners to let the player draw when he presses and moves the mouse:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 | package { import flash.display.Sprite; import flash.events.Event; import flash.events.MouseEvent; public class draw extends Sprite { public var drawing:Boolean=false; public var canvas:Sprite = new Sprite(); public function draw():void { addChild(canvas); canvas.graphics.lineStyle(5) stage.addEventListener(MouseEvent.MOUSE_DOWN,mouse_pressed); stage.addEventListener(MouseEvent.MOUSE_MOVE,mouse_moved); stage.addEventListener(MouseEvent.MOUSE_UP,mouse_released); } public function mouse_pressed(e:MouseEvent):void { drawing=true; canvas.graphics.moveTo(mouseX,mouseY); } public function mouse_moved(e:MouseEvent):void { if (drawing) { canvas.graphics.lineTo(mouseX,mouseY); } } public function mouse_released(e:MouseEvent):void { drawing=false; } } } |
And this is the result: Read more
Scaling objects with Box2D – part 2
In the first part I showed you how to scale a circle.
Now it’s time to scale a square… but before entering in the tutorial, I would like to do some cut/paste theory :)
In Euclidean geometry, uniform scaling or isotropic scaling is a linear transformation that enlarges or increases or diminishes objects; the scale factor is the same in all directions.
In Box2D, I said you can’t scale an object but you can replace the shape with a similar one
Two geometrical objects are called similar if they both have the same shape. More precisely, one is congruent to the result of a uniform scaling (enlarging or shrinking) of the other. Corresponding sides of similar polygons are in proportion, and corresponding angles of similar polygons have the same measure. One can be obtained from the other by uniformly “stretching” the same amount on all directions, possibly with additional rotation and reflection, i.e., both have the same shape, or one has the same shape as the mirror image of the other. For example, all circles are similar to each other, all squares are similar to each other, and all equilateral triangles are similar to each other. On the other hand, ellipses are not all similar to each other, nor are hyperbolas all similar to each other. If two angles of a triangle have measures equal to the measures of two angles of another triangle, then the triangles are similar.
Source: scaling and similarity on Wikipedia.
Now, even with my poor geometry skills, I know you can scale all the kind of shapes as long as you scale the triangles forming them… and you can scale every triangle with a bit of trigonometry.
But this is not the meaning of this tutorial… now I just want to have the same routine scaling both a circle and a rectangle.
The first thing to do when you select a body, is determining the kind of the shape attached to the body. This can be solved with GetType(): applied to a shape, it returns 0 if it’s a b2CircleShape (a circle) and 1 if it’s a b2PolygonShape, such as a rectangle in our example.
Another useful function is GetVertexCount()… it will return the number of vertex, and it’s very useful to determine if you are dealing with triangles, rectangles, or more complex polygons. Remember you should use regular polygons if you don’t want to drive yourself mad with geometry.
Last but not least, GetVertices() will return an array with all vertices… very useful to determine current width and height of our rectangle.
So the code used in the first part becomes: Read more
- Create incredible particle effects with Partigen 2
- PixelBlitz AS3 game framework
- Being a geek in Venezuela
- Box2D tutorial for the absolute beginners – revamped
- Triqui’s Picks #16
- Are you ready for this?
- Box2DFlash 2.1a released – what changed
- Get detailed statistics about your Flash game with SWFStats
- Games that Challenge the World Come2Play contest – $8,000 in prizes
- Triqui’s Picks #15
- Create a Lightbox effect only with CSS - no javascript needed
- Flash game creation tutorial - part 1
- Create a Flash Racing Game Tutorial
- Flash game creation tutorial - part 2
- Make a Flash game like Flash Element Tower Defense - Part 2
- Flash game creation tutorial - part 3
- Make a Flash game like Flash Element Tower Defense - Part 1
- Create a flash draw game like Line Rider or others - part 1
- Create a flash artillery game - step 1
- Triqui MochiAds Arcade plugin for WordPress official page
- Flash game creation tutorial – part 5.2 (4.87/5)
- Create a flash artillery game – step 1 (4.78/5)
- Create a Flash Racing Game Tutorial (4.76/5)
- Create a survival horror game in Flash tutorial – part 1 (4.73/5)
- Flash game creation tutorial – part 3 (4.73/5)
- Creation of a Flash arcade site using WordPress – step 2 (4.73/5)
- Flash game creation tutorial – part 2 (4.70/5)
- Create a flash artillery game – step 2 (4.70/5)
- Flash game creation tutorial – part 1 (4.69/5)
- Create a flash draw game like Line Rider or others – part 1 (4.69/5)





