0
저는 이제 EaselJS로 시작하고 첫 번째 장애물에 부딪 힙니다. 나는 새로운 클래스라는 달걀 만들 수있는 컨테이너 개체를 확장 한 :EaselJS 틱 이벤트 델타 속성이 자식에게 전달되지 않습니다.
(function() {
var Egg = function(color, x, y, cY) {
this.initialize(color, x, y, cY);
}
var e = Egg.prototype = new createjs.Container(); // inherit from Container
e.Container_initialize = e.initialize;
e.initialize = function(color, x, y, cY) {
this.Container_initialize();
this.circle = new createjs.Shape();
this.circle.graphics.beginFill(color).drawCircle(0, 0, 10);
this.circle.x = x;
this.circle.y = y;
this.addChild(this.circle);
this.changeY = cY;
this.addEventListener("tick", this.handleTick);
}
e.handleTick = function(event) {
console.log(event.delta); // undefined!
}
window.Egg = Egg;
}());
을 그리고는 다음과 같이 초기화하고 있습니다 : 계란 handleTick 기능에서
var stage, timeCircle;
function init() {
stage = new createjs.Stage("gameCanvas");
timeCircle = new createjs.Shape();
createjs.Ticker.useRAF = true;
createjs.Ticker.setFPS(30);
createjs.Ticker.addEventListener("tick", tick);
var egg = new Egg("red", 50, 50, 100);
stage.addChild(egg);
var egg2 = new Egg("blue", 100, 50, 50);
stage.addChild(egg2);
}
function tick(event) {
stage.update(event);
}
, 나는 event.delta 속성을 로그 아웃 할 때 , 나는 "undefined"를 얻는다. 스테이지를 통해 이벤트를 통과하면 업데이트가 될 것입니다. 그러면 스테이지의 오브젝트로 전파 될 것입니다.
아, 나는 이벤트 매개 변수 "PARAMS"로는 DisplayObject에 전달 된 방법을 이해하지 않았다 - 감사합니다! – koosa
이 답변에 걸린 모든 사람들을위한 후속 조치로서 : EaselJS v0.8.0은 이제이 혼동을 피하기 위해 디스플레이 목록 틱 이벤트에 '델타'를 표시합니다. – gskinner