Class: MG::Scene
Overview
This class represents a scene, an independent screen or stage of the
application workflow. A scene is responsible for handling events from the
device, providing a physics world for the sprites, and also starting the
game loop. An application must have at least one scene, and the
Scene
class is designed to be subclassed.
Properties (collapse)
-
- (Boolean) debug_physics?
Whether the physics engine should draw debug lines.
-
- (Point) gravity
The gravity of the scene's physics world.
Attributes inherited from Node
#alpha, #anchor_point, #color, #name, #position, #rotation, #scale, #size, #visible?, #z_index
Constructors (collapse)
-
- (Scene) initialize
constructor
The default initializer.
Update Loop (collapse)
-
- (String) schedule(delay, repeat = 0, interval = 0) {|Float| ... }
Schedules a given block for execution.
-
- (Scene) start_update
Starts the update loop.
-
- (Scene) stop_update
Stops the update loop.
-
- (Scene) unschedule(key)
Unschedules a task that's currently running.
-
- (Scene) update(delta)
The update loop method.
Events (collapse)
-
- (Scene) on_accelerate {|Events::Acceleration| ... }
Starts listening for accelerometer events on the receiver.
-
- (Scene) on_contact_begin {|Events::PhysicsContact| ... }
Starts listening for contact begin events from the physics engine.
-
- (Scene) on_touch_begin {|Events::Touch| ... }
Starts listening for touch begin events on the receiver.
-
- (Scene) on_touch_cancel {|Events::Touch| ... }
Starts listening for touch cancel events on the receiver.
-
- (Scene) on_touch_end {|Events::Touch| ... }
Starts listening for touch end events on the receiver.
-
- (Scene) on_touch_move {|Events::Touch| ... }
Starts listening for touch move events on the receiver.
Methods inherited from Node
#add, #children, #clear, #delete, #delete_from_parent, #intersects?, #parent
Constructor Details
- (Scene) initialize
The default initializer. Subclasses can construct the scene interface in this method, as well as providing an implementation for #update, then run the update loop by calling #start_update.
191 |
# File 'motion-game', line 191 def initialize; end |
Instance Attribute Details
- (Boolean) debug_physics?
Returns whether the physics engine should draw debug lines.
275 276 277 |
# File 'motion-game', line 275
def debug_physics?
@debug_physics?
end
|
- (Point) gravity
Returns the gravity of the scene's physics world.
272 273 274 |
# File 'motion-game', line 272 def gravity @gravity end |
Instance Method Details
- (Scene) on_accelerate {|Events::Acceleration| ... }
Starts listening for accelerometer events on the receiver.
260 |
# File 'motion-game', line 260 def on_accelerate; end |
- (Scene) on_contact_begin {|Events::PhysicsContact| ... }
Starts listening for contact begin events from the physics engine.
266 |
# File 'motion-game', line 266 def on_contact_begin; end |
- (Scene) on_touch_begin {|Events::Touch| ... }
Starts listening for touch begin events on the receiver.
236 |
# File 'motion-game', line 236 def on_touch_begin; end |
- (Scene) on_touch_cancel {|Events::Touch| ... }
Starts listening for touch cancel events on the receiver.
254 |
# File 'motion-game', line 254 def on_touch_cancel; end |
- (Scene) on_touch_end {|Events::Touch| ... }
Starts listening for touch end events on the receiver.
242 |
# File 'motion-game', line 242 def on_touch_end; end |
- (Scene) on_touch_move {|Events::Touch| ... }
Starts listening for touch move events on the receiver.
248 |
# File 'motion-game', line 248 def on_touch_move; end |
- (String) schedule(delay, repeat = 0, interval = 0) {|Float| ... }
Schedules a given block for execution.
221 |
# File 'motion-game', line 221 def schedule(delay, repeat=0, interval=0); end |
- (Scene) start_update
Starts the update loop. The #update
method will be called on
this object for every frame.
199 |
# File 'motion-game', line 199 def start_update; end |
- (Scene) stop_update
Stops the update loop. The #update
method will no longer be
called on this object.
204 |
# File 'motion-game', line 204 def stop_update; end |
- (Scene) unschedule(key)
Unschedules a task that's currently running.
227 |
# File 'motion-game', line 227 def unschedule(key); end |
- (Scene) update(delta)
The update loop method. Subclasses can provide a custom implementation of this method. The default implementation is empty.
211 |
# File 'motion-game', line 211 def update(delta); end |