0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

【Playcanvas】オブジェクト間でのイベントの通知

Posted at

オブジェクト間でのイベントの通知は


// イベントの登録
this.app.on(イベント名, イベントの処理, イベントのスコープ);

// 例
this.app.on('game:pause', function (){ }, this);


// イベントの発火
this.app.fire(イベント名);

// 例
this.app.fire('game:pause');

を用います。

イベントの登録は「initialize」で行います。
イベントの発火はボタンのクリック時やキャラクターの死亡時などで行います。

イベントの登録、発火の処理は同じゲームのインスタンス内で共有しています。
ですので別々のスクリプトでイベントの登録、発火を記述することができます。
これにより、各オブジェクト間の結合度が下がります。

0
0
0

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
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?