Class: MG::Scene

Inherits:
Node
  • Object
show all
Defined in:
doc/API_reference.rb

Overview

designed to be subclassed.

Properties collapse

Attributes inherited from Node

#alpha, #anchor_point, #color, #name, #position, #rotation, #scale, #size, #visible?, #z_index

Constructors collapse

Update Loop collapse

Events collapse

Methods inherited from Node

#add, #children, #clear, #delete, #delete_from_parent, #intersects?, #parent, #run_action, #stop_action, #stop_all_actions

Constructor Details

#initializeScene

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 'doc/API_reference.rb', line 551

def initialize; end

Instance Attribute Details

#debug_physics?Boolean

Returns whether the physics engine should draw debug lines.

Returns:

  • (Boolean)

    whether the physics engine should draw debug lines.



635
636
637
# File 'doc/API_reference.rb', line 635

def debug_physics?
  @debug_physics?
end

#gravityPoint

Returns the gravity of the scene’s physics world.

Returns:

  • (Point)

    the gravity of the scene’s physics world.



632
633
634
# File 'doc/API_reference.rb', line 632

def gravity
  @gravity
end

Instance Method Details

#on_accelerate {|Events::Acceleration| ... } ⇒ Scene

Starts listening for accelerometer events on the receiver.

Yields:

  • (Events::Acceleration)

    the given block will be yield when an accelerometer event is received from the device.

Returns:

  • (Scene)

    the receiver.



620
# File 'doc/API_reference.rb', line 620

def on_accelerate; end

#on_contact_begin {|Events::PhysicsContact| ... } ⇒ Scene

Starts listening for contact begin events from the physics engine.

Yields:

  • (Events::PhysicsContact)

    the given block will be yield when a contact event is received from the physics engine.

Returns:

  • (Scene)

    the receiver.



626
# File 'doc/API_reference.rb', line 626

def on_contact_begin; end

#on_touch_begin {|Events::Touch| ... } ⇒ Scene

Starts listening for touch begin events on the receiver.

Yields:

  • (Events::Touch)

    the given block will be yield when a touch begin event is received.

Returns:

  • (Scene)

    the receiver.



596
# File 'doc/API_reference.rb', line 596

def on_touch_begin; end

#on_touch_cancel {|Events::Touch| ... } ⇒ Scene

Starts listening for touch cancel events on the receiver.

Yields:

  • (Events::Touch)

    the given block will be yield when a touch cancel event is received.

Returns:

  • (Scene)

    the receiver.



614
# File 'doc/API_reference.rb', line 614

def on_touch_cancel; end

#on_touch_end {|Events::Touch| ... } ⇒ Scene

Starts listening for touch end events on the receiver.

Yields:

  • (Events::Touch)

    the given block will be yield when a touch end event is received.

Returns:

  • (Scene)

    the receiver.



602
# File 'doc/API_reference.rb', line 602

def on_touch_end; end

#on_touch_move {|Events::Touch| ... } ⇒ Scene

Starts listening for touch move events on the receiver.

Yields:

  • (Events::Touch)

    the given block will be yield when a touch move event is received.

Returns:

  • (Scene)

    the receiver.



608
# File 'doc/API_reference.rb', line 608

def on_touch_move; end

#schedule(delay, repeat = 0, interval = 0) {|Float| ... } ⇒ String

Schedules a given block for execution.

Parameters:

  • delay (Float)

    the duration of the block, in seconds.

  • repeat (Integer) (defaults to: 0)

    the number of times the block should be repeated.

  • interval (Float) (defaults to: 0)

    the interval between repetitions, in seconds.

Yields:

  • (Float)

    the given block will be yield with the delta value, in seconds.

Returns:

  • (String)

    a token representing the task that can be passed to #unschedule when needed.



581
# File 'doc/API_reference.rb', line 581

def schedule(delay, repeat=0, interval=0); end

#start_updateScene

Starts the update loop. The #update method will be called on this object for every frame.

Returns:

  • (Scene)

    the receiver.



559
# File 'doc/API_reference.rb', line 559

def start_update; end

#stop_updateScene

Stops the update loop. The #update method will no longer be called on this object.

Returns:

  • (Scene)

    the receiver.



564
# File 'doc/API_reference.rb', line 564

def stop_update; end

#unschedule(key) ⇒ Scene

Unschedules a task that’s currently running.

Parameters:

  • key (String)

    a token representing the task to unschedule, returned by #schedule.

Returns:

  • (Scene)

    the receiver.



587
# File 'doc/API_reference.rb', 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.

Parameters:

  • delta (Float)

    a value representing the amount of time, in seconds, since the last time this method was called.

Returns:

  • (Scene)

    the receiver.



571
# File 'doc/API_reference.rb', line 571

def update(delta); end