LoginSignup
0

More than 5 years have passed since last update.

RubyKokubanで画像をマウスに追従させる

Posted at

mrubyを使ってインタラクティブアプリケーションを作ることが出来ます。
インストール方法はこちらをどうぞ。 → [最新記事]

表示して、アニメーションさせたら、最後は入力に反応させてみましょう。マウスに画像を追従させます。
Image#set_anchor_percentは画像の基準位置を変更出来る便利なコマンドです。(今回は基準位置を真ん中に変更しています。)

def setup
  @image = Image.load("sample.png")
  @image.set_anchor_percent(0.5, 0.5)
end

def draw
  set_color(Color::White)
  @image.draw(Input.mouse_x, Input.mouse_y)
end
$ kokuban exec image004.rb

動くと楽しいですね。

image004.png

目次

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0