Class: DemCurves::RubygameUtils::EditorHandle

Inherits:
Object
  • Object
show all
Includes:
Rubygame::Sprites::Sprite
Defined in:
lib/rubygame-util/control-handles.rb

Instance Method Summary collapse

Constructor Details

#initialize(loc = [50, 50], size = 10) ⇒ EditorHandle

Returns a new instance of EditorHandle.



41
42
43
44
45
46
47
48
49
50
51
52
53
# File 'lib/rubygame-util/control-handles.rb', line 41

def initialize(loc=[50, 50], size=10)
  @groups =[]
  @depth = 0
  
  @rect = Rubygame::Rect.new 0, 0, size, size
  @rect.c = loc
  
  @image = Rubygame::Surface.new [size, size], 0, [Rubygame::HWSURFACE, Rubygame::SRCALPHA]
  @image.fill([180, 180, 180])
  @attached = false
  
  @constraints = []
end

Instance Method Details

#attach_to(control_point) ⇒ Object



55
56
57
58
59
60
61
# File 'lib/rubygame-util/control-handles.rb', line 55

def attach_to(control_point)
  unless @attached
    @attached = true
    @control_point = control_point
    @rect.c = control_point.loc.to_a
  end
end

#move(rel) ⇒ Object



63
64
65
66
67
# File 'lib/rubygame-util/control-handles.rb', line 63

def move(rel)
  if @attached
    @control_point.shift rel
  end
end

#updateObject



69
70
71
72
73
# File 'lib/rubygame-util/control-handles.rb', line 69

def update
  if @attached
    @rect.c = @control_point.loc.to_a
  end
end