// this.status = EAction.EAT;
this.yukkuri = yukkuri;
this.isMoving = false;
+ this.moveEvent = null;
},
observe: function(){
if(this.yukkuri.isDead()){
}
},
move : function(){
-
+ this.moveEvent.run();
},
walk : function(retryCounter){
if(retryCounter > 15){
var yukkuri = this.yukkuri;
if(yukkuri.isSleeping){
- if(yukkuri.age%10 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
+ if(yukkuri.age%4 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
if(yukkuri.param.sleep <= 0){
yukkuri.param.sleep = 0;
yukkuri.isSleeping = false;
yukkuri.tweet("ゆっくりおきるよ!");
this.status = EAction.THINK;
+ yukkuri.imgBody.tl.resume();
+ yukkuri.imgGroup.tl.resume();
}
}
},
// this.yukkuri.imgGroup.tl.removeFromScene();
},
search : function(){
- if(true)return;
- for (var i = 0, l = game.rootScene.childNodes.length; i < l; i++) {
- var node = game.rootScene.childNodes[i];
+ var nodes = ctl.objArray;
+ // l = game.rootScene.childNodes.length;
+ // l = game.rootScene.childNodes.length;
+ l = nodes.length;
+ for (var i = 0; i < l; i++) {
+ var node = nodes[i];
+ console.log("name:"+node.classname);
if (node instanceof Food) {
-
if(this.yukkuri.within(node, this.yukkuri.range)){
+ console.log("yes:");
//A yukkuri to go to the food area
this.status = EAction.MOVE;
- new MoveEvent({
+ this.moveEvent = new MoveEvent({
"type": 'food',
"targetNode": node,
"myYukkuri": this.yukkuri
});
+ return;
}else{
- // console.log("no:");
+ console.log("no:");
}
}
}
}
});
var MoveEvent = enchant.Class.create({
- initialize: function (dataObj){
- this.move
- }
+ initialize: function (_data){
+ this.data = _data;
+ var yukkuri = this.data.myYukkuri;
+ var node = this.data.targetNode;
+ //food distance
+ if(this.data.type == "food"){
+ 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.tweet("ゆゆ??\nたべものさんはっけんなのぜ!");
+ }
+ },
+ run: function(){
+ if(this.data.type == "food"){
+
+ }
+ }
});
+
var Food = enchant.Class.create(enchant.Sprite,{
initialize: function (type, x, y){
+ this.classname = "Food";
enchant.Sprite.call(this,16,16);
this.image = game.assets[EResPath.OBJECT];
this.frame = 15;
this.y = y;
// this.moveTo(180, 252);
backgroundMap.addChild(this);
+ ctl.objArray.push(this);
}
});
var Okazari = enchant.Class.create(enchant.Sprite,{
initialize: function(){
+ this.classname = "Okazari";
enchant.Sprite.call(this, 64, 64);
this.image = game.assets[EResPath.OKAZARI];
this.x = -CHARA_WIDTH / 2;
});
var Yukkuri = enchant.Class.create(enchant.Sprite,{
initialize: function(x, y){
+ this.classname = "Yukkuri";
this.imgGroup = new Group();
this.imgBody = new Group();
enchant.Sprite.call(this, 64, 64);
runEnterframe:function(){
this.runYukkuri();
this.runHungry();
+ this.runSleep();
},
reverse:function(){
if(this.direction == EDirection.RIGHT){
moveTo:function(x, y, time){
this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
},
- moveBy:function(x, y, time){
- this.imgGroup.tl.moveBy(x, y, time, enchant.Easing.SIN_EASEINOUT);
+ moveBy:function(x, y, time, eventFunctions){
+ // this.imgGroup.tl.moveBy(x, y, time, enchant.Easing.SIN_EASEINOUT);
+ var self = this;
+ console.log("moveby");
+ if(eventFunctions !== undefined){
+ // for(var func in eventFunctions){
+ // eventFunctions[func];
+ // }
+ }
+ 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");
+ }
+ });
},
act: function(){
// this.face.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
// this.hear.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
},
+ getX: function(){
+ return this.imgGroup.x;
+ },
+ getY: function(){
+ return this.imgGroup.y;
+ },
moveX: function(x){
this.imgGroup.x += x;
// this.x += x;
if(this.param.sleep >= 100){
this.param.sleep = 100;
this.isSleeping = true;
+ this.tweet("zzz...zzz...zzz...");
+ this.imgBody.tl.pause();
+ this.imgGroup.tl.pause();
}
}
var Marisa = enchant.Class.create(Yukkuri,{
initialize: function(x, y){
Yukkuri.call(this,x,y);
+ this.classname = "Marisa";
// var xml = this.loadParamsXML("./data/marisa/params.xml");
this.imgGroup.y = y;
this.animation();
this.action = new Action(this);
+ ctl.objArray.push(this);
}
});
// this.runEnterframe = function(){
// },
Marisa.call(this, x, y);
+ this.classname = "Player";
ctl.setPlayer(this);
// this.removeEventListener('enterframe',this.runEnterframe);
this.addEventListener('enterframe', function(){