Flying Wiener Dog

Released Books


An Ember in the Wind


A Foundation in Wisdom

Apps


WordMutation (NEW!)


Orbitual


Permutation


Arcade

Physics Tools

The Physics Tools package is an extension for Stencyl development environment. It provides some computational tools for Stencyl's implementation of Box2D. In particular, it adds blocks for precision trajectories and collision detection along a trajectory.

Downloads:       [physics-tools.zip]       [physics-tools.tar.gz]       [sample stencyl export]

More examples and past releases are available from the Archives Page.
 

Function Reference

Function                        

   

Description

combinedLaunchAngle

 

Returns direction of motion

 

 

jumpPixel

 

Push the actor with enough force to clear the specified distance in pixels (e.g. jump)

 

 

jumpTile

 

Push the actor with enough force to clear the specified distance in tiles (e.g. jump)

 

 

arcRayCast

 

Returns the first actor on the trajectory from x, y at given velocities. The time interval will specify the section of the arc to search for a collision within.

 

 

arcRayCast2

 

Returns a list of all actors on the trajectory from x, y at given velocities. The time interval will specify the section of the arc to search for a collision within.

 

 

trajectoryPosition2

 

Returns the projected x or y position of the actor n seconds into the future.

 

 

combinedLaunchVelocity

 

Returns the velocity with specified horizontal and vertical speeds

 

 

trajectoryPosition3

 

Returns the projected x or y coordinate of a moving body from starting x or y coordinate and velocity n seconds into the future

 

 

launchVelocity

 

Returns the x or y speed necessary to launch a body from (x1,y1) to (x2,y2) at an angle of n degrees.

 

Note: "angle" is used to determine the highest point the projectile will reach before it descends. The image below illustrates the effect "angle" has on the path. A rectangular box is drawn, the width of which is the horizontal distance between the projectile and target. The angle between the two diagonals determines the height.

To form a trajectory that is as high as is far, select an angle of 45 degrees.

 

doLaunch

 

Launch an actor to a specified point. The "angle" parameter behaves as explained above.

 

 

angleCheck

 

Returns true if the "angle" parameter, as used above, is sufficient.

 

In some cases, the "angle" parameter may be too low for the computed trajectory height to reach the intended target. In this case, two errors may be seen if a launch is executed: "PhysicsTools.launchVelocity: Negative discriminant." or "PhysicsTools.doLaunch: Angle insufficient to reach target height."

This block allows the developer to check for this condition before attempting a launch.

 

velocityComponent

 

Returns the horizontal speed (x) or vertical speed (y) component of velocity in a given direction.

 

 

aspectAngle

 

Returns the angle formed by the diagonal connecting (x1,y1) and (x2,y2).

 

 

arcRayCast3

 

Returns the first actor on an arc from (x1,y1) to (x2,y2) at specified velocity.

 

 

arcRayCast4

 

Returns a list of all actors on an arc from (x1,y1) to (x2,y2) at specified velocity.

 

 

getAngle

 

Returns the angle of motion to hit a target at (x2,y2) at a specified velocity.