var mangIcon = null;
var mangTouch = null;
var mangLabel = null;
+var mangMsg = null;
var LabelGroup = enchant.Class.mixClasses(Label, Group,true);
var net = new Net();
//////////////////////////////////////
var CHARA_HEIGHT = 64;
var GAME_WIDTH = 800;
var GAME_HEIGHT = 600;
-var FPS = 15;
+var FPS = 20;
var HUNGRY_MAX = 100;
var EResPath = {
COMMAND : './data/command.png',
OKAZARI : './data/okazari.png',
};
-
+var EFace = {
+ NORMAL:0,
+ TIRED:1,
+ ANGRY:2,
+ CRY1:3,
+ CRY2:4,
+ EAT1:5,
+ EAT2:6,
+ HAPPY1:7,
+ HAPPY2:8,
+ SLEEP:9,
+};
var ECommand = {
WORLD_CURSOR: 0,
WORLD_TARGET: 1,
LEFT : 0,
RIGHT: 1,
};
-
+var EMsg = {
+ WALK: 0,
+ SLEEP: 1,
+ EAT: 2,
+};
window.onload = function(){
//init game
var def = new Object();
this.observe();
switch(this.status){
case EAction.THINK:
- if(this.yukkuri.age%6 === 0){
+ if(this.yukkuri.age%2 === 0){
+ this.yukkuri.changeFace();
this.search();
}
break;
this.isMoving = true;
this.yukkuri.reverse();
this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
+ mangMsg.output(this.yukkuri,EMsg.WALK);
}else{
// console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
this.walk(retryCounter+1);
this.food = _data.targetNode;
this.action = _data.action;
this.action.setStatus(EAction.EAT_WAIT);
- this.yukkuri.tweet("む~しゃむ~しゃ!");
+ this.yukkuri.tweet("む~しゃむ~しゃ!それなり~");
+ mangMsg.output(this.yukkuri, EMsg.EAT);
+ this.yukkuri.setFaceImage(EFace.EAT2);
+ // this.yukkuri.image = game.assets[EResPath.MARISA_];
// var sec = FPS * (this.yukkuri.param.hungry/10 + 3);
var sec = FPS * 3;
if(typeof e === "undefined")return;
if(self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
self.action.setStatus(EAction.THINK);
+ self.yukkuri.setFaceImage(EFace.NORMAL);
}else{
self.action.setStatus(EAction.EAT_START);
}
initialize: function(x, y){
ObjSprite.call(this, 64, 64);
this.classname = "Yukkuri";
- this.imgGroup = new Group();
- this.imgBody = new Group();
+ this.imgGroup = new SpriteGroup();
+ this.imgBody = new SpriteGroup();
+ this.imgGroup.id = guid();
+ this.imgBody.id = guid();
this.x = -CHARA_WIDTH / 2;
this.y = -CHARA_HEIGHT / 2;
this.vx = 0;
// this.shadow.y += y;
// this._tweet.y += y;
},
- changeFace: function(erespath){
- this.face.image = game.assets[erespath];
- },
+ // changeFace: function(erespath){
+ // this.face.image = game.assets[erespath];
+ // },
loadParamsXML: function(url){
var http = new JKL.ParseXML( url );
return http.parse();
}
},
+ changeFace: function(){
+ if(this.param.yukkuri >= 80){
+ this.setFaceImage(EFace.HAPPY1);
+ }
+ else if(this.param.yukkuri >= 50){
+ this.setFaceImage(EFace.NORMAL);
+ }
+ else if(this.param.yukkuri >= 30){
+ this.setFaceImage(EFace.TIRED);
+ }
+ else if(this.param.yukkuri >= 10){
+ this.setFaceImage(EFace.CRY1);
+ }
+ else if(this.param.yukkuri >= 1){
+ this.setFaceImage(EFace.CRY2);
+ }
+ },
getRange: function(){
return this.param.range;
},
this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
this.shadow.x = 0 + this.x;
this.shadow.y = CHARA_HEIGHT / 16 + this.x;
+ this.shadow.image._element.style.zIndex = 2;
+
+ this._style.zIndex = 5;
this.face = new enchant.Sprite(64, 64);
this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
this.face.x = -CHARA_WIDTH / 2;
this.face.y = -CHARA_HEIGHT / 2;
+ this.face._style.zIndex = 0;
+
+ this.faceStatus ={};
+ this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
+ this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
+ this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
+ this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
+ this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
+ this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
+ this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
+ this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
+ this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
+ this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
+
this.hear = new enchant.Sprite(64, 64);
this.hear.image = game.assets[EResPath.MARISA_HEAR];
this.hear.x = -CHARA_WIDTH / 2;
this.hear.y = -CHARA_HEIGHT / 2;
+ this.hear._style.zIndex = 0;
this.okazari = new Okazari();
+ this.okazari.image._element.style.zIndex = 1;
+
+ // this.imgGroup._style.zIndex = 1;
+
this.imgGroup.addChild(this.shadow);
this.imgBody.addChild(this);
this.imgBody.addChild(this.face);
this.imgGroup.addChild(this.imgBody);
backgroundMap.addChild(this.imgGroup);
this._tweet = new TTweet(148, 64);
+ this._tweet.image._element.style.zIndex = 20;
this.imgGroup.addChild(this._tweet);
this.imgGroup.x = x;
this.action = new Action(this);
this.id = guid();
ctl.addObj(this);
+ },
+ setFaceImage: function(eface){
+ var path = this.faceStatus[eface];
+ this.face.image = game.assets[path];
}
});
var Player = enchant.Class.create(Marisa,{
///////////////////////////////////////////////
//Action pattern for debug
- // if(game.input.left){
- // this.changeFace(EResPath.MARISA_FACE_TIRED);
- // this.moveX(-10);
- // this.direction = EDirection.LEFT;
- // }
- // if(game.input.right){
- // this.moveX(10);
- // this.direction = EDirection.RIGHT;
- // }
- // if(game.input.up){
- // this.moveY(-10);
- // // this.tweet("ゆっくりしていってね!");
- // }
- // if(game.input.down){
- // this.moveY(10);
- // }
+ if(game.input.left){
+ // this.changeFace(EResPath.MARISA_FACE_TIRED);
+ this.moveX(-10);
+ this.direction = EDirection.LEFT;
+ }
+ if(game.input.right){
+ this.moveX(10);
+ this.direction = EDirection.RIGHT;
+ }
+ if(game.input.up){
+ this.moveY(-10);
+ this.tweet("ゆっくりしていってね!");
+ }
+ if(game.input.down){
+ this.moveY(10);
+ }
///////////////////////////////////////////////
this.reverse();
// if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
game.onload = function(){
def.Food = Food;
mangTouch = new MangTouch(ctl);
+ mangMsg = new MangMsg(ctl);
ctl.setDefined(def);
backgroundMap.image = game.assets[EResPath.MAP0];
backgroundMap.loadData(_mapData);
//main frame
mangLabel.draw(player);
});
+
+ this.addEventListener('enterframe', function(){
+ //The priority processing of display instead of z-index
+ backgroundMap.childNodes.sort(
+ function(a,b){
+ if(typeof a.id === "undefined" && typeof b.id === "undefined"){
+ return 0;
+ }
+ else if(typeof a.id === "undefined"){
+ return -1;
+ }
+ else if(typeof b.id === "undefined"){
+ return 1;
+ }
+ if(a.y < b.y)return -1;
+ if(a.y > b.y)return 1;
+ return 0;
+ }
+ );
+ });
+
};
game.start();
};