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
-
#debug_physics? ⇒ Boolean
Whether the physics engine should draw debug lines.
-
#gravity ⇒ Point
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
-
#initialize ⇒ Scene
constructor
The default initializer.
Update Loop collapse
-
#schedule(delay, repeat = 0, interval = 0) {|Float| ... } ⇒ String
Schedules a given block for execution.
-
#start_update ⇒ Scene
Starts the update loop.
-
#stop_update ⇒ Scene
Stops the update loop.
-
#unschedule(key) ⇒ Scene
Unschedules a task that's currently running.
-
#update(delta) ⇒ Scene
The update loop method.
Events collapse
-
#on_accelerate {|Events::Acceleration| ... } ⇒ Scene
Starts listening for accelerometer events on the receiver.
-
#on_contact_begin {|Events::PhysicsContact| ... } ⇒ Scene
Starts listening for contact begin events from the physics engine.
-
#on_touch_begin {|Events::Touch| ... } ⇒ Scene
Starts listening for touch begin events on the receiver.
-
#on_touch_cancel {|Events::Touch| ... } ⇒ Scene
Starts listening for touch cancel events on the receiver.
-
#on_touch_end {|Events::Touch| ... } ⇒ Scene
Starts listening for touch end events on the receiver.
-
#on_touch_move {|Events::Touch| ... } ⇒ Scene
Starts listening for touch move events on the receiver.
Methods inherited from Node
#add, #children, #clear, #delete, #delete_from_parent, #intersects?, #parent, #run_action, #stop_action, #stop_all_actions
Constructor Details
#initialize ⇒ Scene
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.
551 |
# File 'motion-game', line 551 def initialize; end |
Instance Attribute Details
#debug_physics? ⇒ Boolean
Returns whether the physics engine should draw debug lines.
635 636 637 |
# File 'motion-game', line 635
def debug_physics?
@debug_physics?
end
|
#gravity ⇒ Point
Returns the gravity of the scene's physics world.
632 633 634 |
# File 'motion-game', line 632 def gravity @gravity end |
Instance Method Details
#on_accelerate {|Events::Acceleration| ... } ⇒ Scene
Starts listening for accelerometer events on the receiver.
620 |
# File 'motion-game', line 620 def on_accelerate; end |
#on_contact_begin {|Events::PhysicsContact| ... } ⇒ Scene
Starts listening for contact begin events from the physics engine.
626 |
# File 'motion-game', line 626 def on_contact_begin; end |
#on_touch_begin {|Events::Touch| ... } ⇒ Scene
Starts listening for touch begin events on the receiver.
596 |
# File 'motion-game', line 596 def on_touch_begin; end |
#on_touch_cancel {|Events::Touch| ... } ⇒ Scene
Starts listening for touch cancel events on the receiver.
614 |
# File 'motion-game', line 614 def on_touch_cancel; end |
#on_touch_end {|Events::Touch| ... } ⇒ Scene
Starts listening for touch end events on the receiver.
602 |
# File 'motion-game', line 602 def on_touch_end; end |
#on_touch_move {|Events::Touch| ... } ⇒ Scene
Starts listening for touch move events on the receiver.
608 |
# File 'motion-game', line 608 def on_touch_move; end |
#schedule(delay, repeat = 0, interval = 0) {|Float| ... } ⇒ String
Schedules a given block for execution.
581 |
# File 'motion-game', line 581 def schedule(delay, repeat=0, interval=0); end |
#start_update ⇒ Scene
Starts the update loop. The #update
method will be called on
this object for every frame.
559 |
# File 'motion-game', line 559 def start_update; end |
#stop_update ⇒ Scene
Stops the update loop. The #update
method will no longer be
called on this object.
564 |
# File 'motion-game', line 564 def stop_update; end |
#unschedule(key) ⇒ Scene
Unschedules a task that's currently running.
587 |
# File 'motion-game', line 587 def unschedule(key); end |
#update(delta) ⇒ Scene
The update loop method. Subclasses can provide a custom implementation of this method. The default implementation is empty.
571 |
# File 'motion-game', line 571 def update(delta); end |