case EAction.DEAD:
this.dead();
break;
+ case EAction.EAT:
+ break;
}
},
move : function(){
this.moveEvent = new MoveEvent({
"type": 'food',
"targetNode": node,
+ "action": this,
"myYukkuri": this.yukkuri
});
return;
this.status = EAction.WALK;
}
});
- var MoveEvent = enchant.Class.create({
+ var Event = enchant.Class.create({
+ initialize: function (){
+ },
+ onactionstart:function(e){
+ },
+ onactiontick:function(e){
+ },
+ onactionend:function(e){
+ }
+ });
+ var MoveEvent = enchant.Class.create(Event,{
initialize: function (_data){
this.data = _data;
+ var self = this;
var yukkuri = this.data.myYukkuri;
var node = this.data.targetNode;
//food distance
yukkuri.vx = node.x - yukkuri.getX();
yukkuri.vy = node.y - yukkuri.getY();
var frame = 150;
- yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame);
-
- yukkuri.addEventListener(enchant.Event.ACTION_END, function(evt) {
- console.log("end");
+ yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
+ "onactionstart": this.onactionstart,
+ "onactiontick": this.onactiontick,
+ "onactionend": this.onactionend
});
-
- yukkuri.tweet("ゆゆ??\nたべものさんはっけんなのぜ!");
}
},
+ onactionstart:function(e){
+ if(typeof e === "undefined")return;
+ yukkuri.tweet("ゆゆ??\nたべものさんはっけんなのぜ!");
+ },
+ onactiontick:function(e){
+ if(typeof e === "undefined")return;
+ console.log("onactiontic");
+ },
+ onactionend:function(e){
+ if(typeof e === "undefined")return;
+ yukkuri.tweet("む~しゃむ~しゃするのぜ!");
+ self.data.action = EAction.EAT;
+ },
run: function(){
if(this.data.type == "food"){
moveBy:function(x, y, time, eventFunctions){
// this.imgGroup.tl.moveBy(x, y, time, enchant.Easing.SIN_EASEINOUT);
var self = this;
- console.log("moveby");
+ var params = {
+ x: function() {
+ return self.imgGroup.x + x;
+ },
+ y: function() {
+ return self.imgGroup.y + y;
+ },
+ time: time,
+ easing: enchant.Easing.SIN_EASEINOUT
+ };
if(eventFunctions !== undefined){
- // for(var func in eventFunctions){
- // eventFunctions[func];
- // }
+ for(var key in eventFunctions){
+ params[key] = eventFunctions[key];
+ }
}
- this.imgGroup.tl.tween({
- x: function() {
- return self.imgGroup.x + x;
- },
- y: function() {
- return self.imgGroup.y + y;
- },
- time: time,
- easing: enchant.Easing.SIN_EASEINOUT,
- "onactionstart": function(e){
- console.log("action start");
- },
- "onactionend": function(e){
- console.log("actionenddd");
- }
- });
+ this.imgGroup.tl.tween(params);
},
act: function(){