module Smalruby3::SpriteMethod::Control

Control category methods

Constants

STOP_OPTION

Public Instance Methods

create_clone(option) click to toggle source
# File lib/smalruby3/sprite_method/control.rb, line 42
def create_clone(option)
  if option == "_myself_"
    # 自分自身のコピーをつくる
    cloned = clone
    # 自分自身がつくったものや、お願いしたこともコピーする
    cloned.instance_variable_set("@dxruby_sprite", DXRuby::Sprite.new(0, 0))
    cloned.send(:sync_costumes)
  end
  cloned.name += rand(1000000).to_s
  World.instance.add_target(cloned)
end
delete_this_clone() click to toggle source
# File lib/smalruby3/sprite_method/control.rb, line 54
def delete_this_clone
  raise NotImplementedError, "not implemented: delete_this_clone"
end
forever() { || ... } click to toggle source
# File lib/smalruby3/sprite_method/control.rb, line 18
def forever(&_block)
  loop do
    yield
    wait
  end
end
repeat(num) { || ... } click to toggle source
# File lib/smalruby3/sprite_method/control.rb, line 11
def repeat(num, &_block)
  num.times do
    yield
    wait
  end
end
stop(option) click to toggle source
# File lib/smalruby3/sprite_method/control.rb, line 25
def stop(option)
  case option
  when STOP_OPTION[:all]
    raise StopAll
  when STOP_OPTION[:this_script]
    raise StopThisScript
  when STOP_OPTION[:other_scripts]
    raise StopOtherScripts
  else
    raise ArgumentError.new("invalid option: #{option}")
  end
end
wait() click to toggle source
# File lib/smalruby3/sprite_method/control.rb, line 38
def wait
  Smalruby3.wait
end