登録したイベントを削除する
// グローバルに展開
phina.globalize();
// メインシーン
phina.define("MainScene", {
// 継承
superClass: 'DisplayScene',
//初期化
init: function () {
//親クラス初期化
this.superInit();
//背景色
this.backgroundColor = 'lightgrey';
// Shapeを作成してシーンに追加
var shape = Shape().addChildTo(this).setPosition(320, 480);
//背景色設定
shape.backgroundColor = 'red';
//タッチを可能にする
shape.setInteractive(true);
//タッチ関数
var touchFunc = function () {
alert('タッチされました');
//2度と呼ばないよう解除する
shape.off('pointstart', touchFunc);
};
//タッチ開始時に呼ばれる関数を登録
shape.on('pointstart', touchFunc);
},
});
//メイン処理
phina.main(function () {
// アプリケーションを生成
var app = GameApp({
// MainSceneから開始
startLabel: 'main',
});
// fps表示
//app.enableStats();
//実行
app.run();
});
▷イベントを削除する
var touchFunc = function () {
alert('タッチされました');
//2度と呼ばないよう解除する
shape.off('pointstart', touchFunc);
};
offメソッドを使って登録したイベントを削除する。