Penner AS2 ProFMX: PhysicsParticle Example

ElasticForce

Click image to view demo


Click around above and you will see an example using the ElasticForce, Force, and PhysicsParticle classes from the Chapter 11 Penner AS2 post

To replicate this example, add a circle MovieClip to the stage with an instance name of “ball”.
Then on the root timeline add the following code:

import com.robertpenner.physics.PhysicsParticle;
import com.robertpenner.physics.forces.ElasticForce;

var p:PhysicsParticle = new PhysicsParticle(ball, ball._x, ball._y);
p.setFriction(.1);
var eForce:ElasticForce = new ElasticForce(130, 70, .2);
p.addForce("elastic", eForce);

this.onMouseDown = function() {
	eForce.setAnchor(this._xmouse, this._ymouse);
}

stop();
This entry was posted in Flash. Bookmark the permalink. Trackbacks are closed, but you can post a comment.

Post a Comment

Your email is never published nor shared. Required fields are marked *

*
*

You may use these HTML tags and attributes: <a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code> <del datetime=""> <em> <i> <q cite=""> <strike> <strong>

Subscribe without commenting

  • Pages

  • Categories

  • Archives