Nspired Lua クラス入門非公式訳

クラスを使う 7 of 7, オブジェクトを複製する

--[[ 「任意のオブジェクトを複製する」 クリックしたオブジェクトが複製される。 どれかオブジェクトが選択状態にあるときに enter キーを押すとそのオブジェクトが複製される。 参考: http://compasstech.com.au/TNS_Authoring/Scripting/script_tut11.htm…

クラスを使う 6, 任意のオブジェクトをマウスで動かす

-- 任意のオブジェクトをマウスで動かす。 -- 参考: http://compasstech.com.au/TNS_Authoring/Scripting/script_tut11.html ~ tut14.html require "color" W = platform.window:width() H = platform.window:height() TrackedObject = nil TrackOffsetx = …

クラスを使う 5, 任意のオブジェクトをクリックして選択する

-- 任意のオブジェクトをクリックして選択する -- 参考: http://compasstech.com.au/TNS_Authoring/Scripting/script_tut11.html ~ tut15.html require "color" W = platform.window:width() H = platform.window:height() TrackedObject = nil TrackOffset…

クラスを使う 4, 注目オブジェクトを矢印キーで動かす

-- 注目オブジェクトを矢印キーで動かす -- 参考: -- 全体については http://compasstech.com.au/TNS_Authoring/Scripting/script_tut11.html ~ tut15.html -- 下の move メソッドについては https://inspired-lua.org/index.php/2011/05/5-object-classes/…

クラスを使う 3, 複数のオブジェクトを tab キーで巡廻する

-- 複数のオブジェクトを tab キーで巡廻する。 -- 参考: http://compasstech.com.au/TNS_Authoring/Scripting/script_tut14.html require "color" TrackedObject = nil Square = class() function Square:init(x, y, sideLen, color) self.x = x self.y = y…

クラスを使う 2, 包含判定をする

-- 包含判定をする。 -- 参考: http://compasstech.com.au/TNS_Authoring/Scripting/script_tut11.html require "color" Square = class() -- Square クラスを作る。 function Square:init(x, y, width, height) self.x = x self.y = y self.width = width s…

クラスを使う 1

box = class() -- 何も継承せずに box クラスを作る。 function box:init(x, y, w, h, color) -- box クラスを初期化する。 self.x = x self.y = y self.w = w self.h = h self.color = color end function box:paint(gc) -- box クラスの描画メソッドを作る…