エンバー成分(Iこのためhttps://github.com/Ferdev/ember-cli-pixijs使用)にPixi.jsからイベントを送信http://ipotaje.es/en/complete-html5-concentration-game-made-with-pixi-js-3/Iは、例えばピクシーゲームはエンバーアプリケーション内で実行しているキャンバスを有する
私のPixiコンポーネントには、ゲームロジックではなく描画/レンダリングロジックのみが含まれています。それは外部クラスに保存されています。私はlog
というアクションを呼び出す必要があります。 、
import PIXI from 'pixi';
var PairsGame = function() {};
PairsGame.prototype.init = function (renderer)
{
this.renderer = renderer;
// create an empty container
this.gameContainer = new PIXI.Container();
const graphics = new PIXI.Graphics();
this.gameContainer.addChild(graphics);
// allow chain calling
return this;
};
PairsGame.prototype.preload = function()
{ // importing a texture atlas created with texturepacker
var tileAtlas = ["assets/images/images.json"];
// create a new loader
PIXI.loader.add(tileAtlas)
// use callback
.once('complete', this.onLoaded.bind(this))
//begin load
.load();
//allow chain calling
return this;
};
PairsGame.prototype.animate = function()
{
this.renderer.render(this.gameContainer);
requestAnimationFrame(this.animate.bind(this));
//allow chain calling
return this;
};
...
ET CETERA
I WOULD LIKE TO CALL THE log ACTION FROM THESE METHODS
...
は、今私は、私は特定のアクションを取ることができるように私のエンバー・コンポーネントに、各ターンに「成功」か「失敗」というメッセージを送信したいと思います(例:ゲームのファイルは次のようになります単純に 'success'/'failure'をコンソールに記録してください)。それを達成する方法は何ですか?
私は解決策hereを見てみましたとピクシーコードで
Ember.Instrumentation.instrument("pixi.gameEvent", 'success');
を置くが、加入者は何も受信しないように思われます。
ああ、これはもちろん動作します。私は 'sendAction'で送信するコマンドにアクション名をマップする必要がありました(http://coryforsyth.com/2014/09/24/communicating-with-ember-js-components-using-sendaction/)しかし、これは正しい軌道に乗った。 –
それを動作させるには、コンポーネントからルートに 'log'アクションを移動する必要がありました。理由は分かりませんし、その行動がコンポーネントに入れられる方が適切だと私は気になります。 –
これは、コンポーネント間の通信に使用される 'sendAction'と、ルーティングするためのコントローラ間の通信に使用される' send'という現象です。 – kumkanillam