この記事はニンテンドーDS向けエミュレータの一つである「DeSmuME」(以降Desmume)のLua用APIの非公式日本語リファレンスです。今回はstylusライブラリについてのリファレンスです。
このリファレンスは非公式の日本語リファレンスです。そもそも英語のリファレンスも公式のリファレンスもありません。
さらに詳細の仕様を確認したい場合はDesmumeのソースコードを参照することを推奨します。
→https://github.com/TASEmulators/desmume/blob/master/desmume/src/lua-engine.cpp
stylus.get()
タッチ操作のX座標Y座標とタッチしていたかを取得する。(1F前の情報)
引数
無し nil
戻り値
table
型
<キー>
[x]:X座標 int
型
[y]:Y座標 int
型
[touch]:タッチの有無 boolean
型
local function Fn()
local table = {}
table = stylus.get()
if table.touch then
gui.text(0,10,"X: "..table.x)
gui.text(0,20,"Y: "..table.y)
end
end
gui.register(Fn)
stylus.peek()
現在のタッチ操作のX座標Y座標とタッチしているかを取得する。
引数
無し nil
戻り値
table
型
<キー>
[x]:X座標 int
型
[y]:Y座標 int
型
[touch]:タッチの有無 boolean
型
local function Fn()
local table = {}
table = stylus.peek()
if table.touch then
gui.text(0,10,"X: "..table.x)
gui.text(0,20,"Y: "..table.y)
end
end
gui.register(Fn)
現在情報なので一時停止中でもとにかく取得します。
sylus.set()
引数
第一引数 操作内容
table
型
<キー>
[x]:X座標 int
型
[y]:Y座標 int
型
[touch]:タッチの有無 boolean
型
戻り値
無し nil
local table = {}
table.x = 100
table.y = 100
table.touch = true
stylus.set(table)
実際に使う際にはemu.registerbefore()で呼び出すかemu.registerboundary()で呼び出さないと描画が更新されずにdesyncする。
サンプルコードは一回切りのコードで、なおかつframe advance操作を行っていない。これはあくまでも動作確認用コード
代替名一覧
以下の関数でコードを書いても右側の関数として認識されます。
stylus.read()
→stylus.get()
stylus.write()
→stylus.set()