Class: Util::DragSprite

Inherits:
Object show all
Defined in:
scripts/01000 Util/00700 DragSprite.rb

Overview

Note:

Draggable stuff should respond to simple_mouse_in? and set_position

Helper that allow sprites to be dragged

This helper can manage various sprites and each sprite can have 3 procs :

- start_drag: a proc called with sprite as argument when a sprite starts being dragged
- update_drag: a proc called with sprite as argument each time the mouse move (the sprite is moved automatically)
- end_drag: a proc called when the sprite stops being dragged (usefull to put the sprite back to its regular pos)

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeDragSprite

Create the DragSprite interface

Instance Attribute Details

#dragging#simple_mouse_in? (readonly)

Return the sprite that is being dragged

Returns:

  • (#simple_mouse_in?)

Instance Method Details

#add(sprite, start_drag: nil, update_drag: nil, end_drag: nil)

Add a sprite to drag

Parameters:

  • sprite (#simple_mouse_in?)

    The sprite to drag

  • start_drag (Proc(sprite)) (defaults to: nil)

    the proc to call when the sprite start being dragged

  • update_drag (Proc(sprite)) (defaults to: nil)

    the proc to call when the sprite is being dragged

  • end_drag (Proc(sprite)) (defaults to: nil)

    the proc to call when the sprite stop being dragged

#update

Update the draging process