この文書の現在のバージョンと選択したバージョンの差分を表示します。
— |
phinajs:button [2017/12/26 06:51] (現在) kaneda 作成 |
||
---|---|---|---|
ライン 1: | ライン 1: | ||
+ | ====== タッチ操作で反応するボタン ====== | ||
+ | |||
+ | SpriteやShapeのonpointstartやonpointendを設定することでタッチ操作に反応するボタンを作ることができます。 | ||
+ | 事前にsetInteractiveにtrueを指定しておく必要があります。 | ||
+ | |||
+ | <code> | ||
+ | this.button = RectangleShape({ | ||
+ | height: BUTTON_HEIGHT, | ||
+ | width: BUTTON_WIDTH, | ||
+ | }); | ||
+ | this.button.addChildTo(this.base); | ||
+ | |||
+ | this.button.setInteractive(true); | ||
+ | |||
+ | this.button.onpointstart = function() { | ||
+ | // タッチ開始時の処理 | ||
+ | }; | ||
+ | |||
+ | this.button.onpointend = function() { | ||
+ | // タッチ終了時の処理 | ||
+ | }; | ||
+ | </code> | ||