Documentation

WHAT WE GOT

AABB
Physics Environment

Animation
Actions & Animations

Array
Support Classes

Audio
Sounds & Music

Audio Effect
Sounds & Music

Background Audio
Sounds & Music

Bezier
Actions & Animations

Blink
Actions & Animations

Body
Physics Environment

Callback
Actions & Animations

Chain Shape
Physics Environment

Circle Shape
Physics Environment

Color
Support Classes

Delay
Actions & Animations

Device
Support Classes

Director
Essentials

Ease
Actions & Animations

Edge Shape
Physics Environment

Event
Support Classes

Fade
Actions & Animations

Filter
Physics Environment

Fixture
Physics Environment

Jump
Actions & Animations

Label
User Interface

Layer
Essentials

Layer Color
Essentials

Liquid
Actions & Animations

Mass Data
Physics Environment

Menu
User Interface

Menu Image
User Interface

Menu Label
User Interface

Move
Actions & Animations

Numeric
Support Clases

Object Layer
Tiled Maps

Physics Sprite
Physics Environment

Place
Actions & Animations

Point
Support Classes

Polygon Shape
Physics Environment

Repeat
Actions & Animations

Rotate
Actions & Animations

Scale
Actions & Animations

Scene
Essentials

Screen
Support Classes

Sequence
Actions & Animations

Shape
Physics Environment

Shuffle
Actions & Animations

Size
Support Classes

Skew
Actions & Animations

Spawn
Actions & Animations

Split
Actions & Animations

Sprite
Essentials

Sprite Batch
Essentials

Sprite Frame Cache
Essentials

Tile Layer
Tiled Maps

Tile Map
Tiled Maps

Tile Set
Tiled Maps

Tint
Actions & Animations

Touch
Support Classes

Turn
Actions & Animations

Twirl
Actions & Animations

Visibility
Actions & Animations

Wave
Actions & Animations

Wiggle
Actions & Animations

World
Physics Environment

PHYSICS ENVIRONMENT

Physics Sprite

The Physics Sprite class is the link between the Physics Environment and the Game Logic: being a subclass of Sprite and containing a physics Body, it combines the functionality of both.

Basically it will update the position and rotation properties on both objects. So when for example the body receives a force, the sprite will move as well. On the other side when the Sprite position is changed also the Body's.

Also it participates in the physics collision detection being passed as argument in the World's On Collide method and received as parameter in the method's block.

For more information, see: Sprite documentation page.
For more information, see: Body documentation page.
For more information, see: World documentation page.

Watch out!

Running actions on the Physics Sprite is supported but experimental.

New

Creates a new instance of the PhysicsSprite:

physics_sprite = PhysicsSprite.new file_name: 'space_ship.png', body: physics_body
More intel!

The Physics Sprite supports all the possible initializations of the Sprite class and adds 'body:' as an additional option for passing the physics Body.

Level Up!

It supports the custom options documented in the Sprite New method, which are very useful at collision detection time.

For more information, see: Sprite documentation page.

Body

Gets or Sets the PhysicsSprite's body:

physics_sprite.body = body

# The following is true
physics_sprite.body == body