2 //////////////////////////////////////
9 var LabelGroup = enchant.Class.mixClasses(Label, Group,true);
11 //////////////////////////////////////
13 //////////////////////////////////////
14 var PALYER_INIT_X = 100;
15 var PALYER_INIT_Y = 100;
17 var CHARA_HEIGHT = 64;
19 var GAME_HEIGHT = 600;
24 YUKKURI_BASE : './data/yukkuri_base.png',
25 YUKKURI_BODY_DEAD : './data/yukkuri_dead.png',
26 YUKKURI_UNUN : './data/unun.png',
27 YUKKURI_SHADOW : './data/shadow.png',
28 MARISA_FACE_NORMAL : './data/marisa/face_normal1.png',
29 MARISA_FACE_TIRED : './data/marisa/face_tired1.png',
30 MARISA_FACE_ANGRY : './data/marisa/face_angry1.png',
31 MARISA_FACE_CRY1 : './data/marisa/face_cry1.png',
32 MARISA_FACE_CRY2 : './data/marisa/face_cry2.png',
33 MARISA_FACE_EAT1 : './data/marisa/face_eat1.png',
34 MARISA_FACE_EAT2 : './data/marisa/face_eat2.png',
35 MARISA_FACE_HAPPY1 : './data/marisa/face_happy1.png',
36 MARISA_FACE_HAPPY2 : './data/marisa/face_happy2.png',
37 MARISA_FACE_SLEEP : './data/marisa/face_sleep1.png',
38 MARISA_HEAR : './data/marisa/hear1.png',
39 OBJECT : './data/object.png',
40 MAP0 : './data/map0.png',
41 COMMAND : './data/command.png',
42 OKAZARI : './data/okazari.png',
76 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
88 MOVE_TO_EAT_START: 10,
89 MOVE_TO_EAT_UNDERWAY: 11,
93 UNUN_SMELL_START : 15,
112 include("./lang/ja.js");
113 window.onload = function(){
116 var def = new Object();
117 var foodGroup = new Group();
118 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
119 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
120 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
121 var game = new Game(GAME_WIDTH, GAME_HEIGHT);
125 for(var _v in EResPath){
126 _loadArr[i] = EResPath[_v];
129 game.preload(_loadArr);
130 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
131 var backgroundMap = new MapGroup(16, 16);
132 include("./class.js");
133 include("./ctrl.js");
136 ctl.setBackgroundMap(backgroundMap);
137 var Action = enchant.Class.create({
138 initialize: function (yukkuri){
139 this.status = EAction.THINK;
140 this.yukkuri = yukkuri;
141 this.isMoving = false;
142 this.targetNode = null;
144 setStatus: function(eaction){
145 this.status = eaction;
148 if(this.yukkuri.isDead()){
149 this.status = EAction.DEAD;
151 else if(this.yukkuri.isSleep()){
152 this.status = EAction.SLEEP;
163 if(this.yukkuri.age%2 === 0){
164 if(this.yukkuri.getUnun() >= 80){
165 this.setStatus(EAction.UNUN_START);
167 // this.yukkuri.param.yukkuri -= 1;
168 this.yukkuri.changeFace();
174 case EAction.MOVE_TO_EAT_START:
175 this.move_to_eat_start();
177 case EAction.MOVE_TO_EAT_UNDERWAY:
189 case EAction.EAT_START:
192 case EAction.EAT_WAIT:
194 case EAction.UNUN_START:
197 case EAction.UNUN_WAIT:
199 case EAction.MOVE_TO_COMMAND:
200 this.move_to_command();
202 case EAction.UNUN_SMELL_START:
203 this.unun_smell_start();
208 move_to_eat_start : function(){
211 "targetNode": this.targetNode,
213 "myYukkuri": this.yukkuri
216 walk : function(retryCounter){
217 if(retryCounter > 15){
219 this.status = EAction.NONE;
220 console.log("retryCount over");
223 if(this.yukkuri.imgGroup.tl.queue.length === 0){
226 this.isMoving = false;
227 this.status = EAction.THINK;
231 // this.isMoving = true;
232 var xpos = 150 + rand(40) - (retryCounter * 10);
233 var ypos = 150 + rand(40) - (retryCounter * 10);
236 this.yukkuri.vy = -ypos;
238 else if(rand(8) == 1){
239 this.yukkuri.vx = xpos;
240 this.yukkuri.vy = -ypos;
241 this.yukkuri.direction = EDirection.RIGHT;
243 else if(rand(8) == 2){
244 this.yukkuri.vx = xpos;
246 this.yukkuri.direction = EDirection.RIGHT;
248 else if(rand(8) == 3){
249 this.yukkuri.vx = xpos;
250 this.yukkuri.vy = ypos;
251 this.yukkuri.direction = EDirection.RIGHT;
253 else if(rand(8) == 4){
255 this.yukkuri.vy = ypos;
257 else if(rand(8) == 5){
258 this.yukkuri.vx = -xpos;
259 this.yukkuri.vy = ypos;
260 this.yukkuri.direction = EDirection.LEFT;
262 else if(rand(8) == 6){
263 this.yukkuri.vx = -xpos;
265 this.yukkuri.direction = EDirection.LEFT;
267 else if(rand(8) == 7){
268 this.yukkuri.vx = -xpos;
269 this.yukkuri.vy = -ypos;
270 this.yukkuri.direction = EDirection.LEFT;
272 if (this.yukkuri.vx || this.yukkuri.vy) {
273 var map = ctl.backgroundMap;
274 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
275 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
276 var x = this.yukkuri.imgGroup.x + this.yukkuri.vx;
277 var y = this.yukkuri.imgGroup.y + this.yukkuri.vy + this.yukkuri.height / 2;
278 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
279 // console.log("あたってないよ:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
280 // console.log("X:" + this.yukkuri.moveX);
281 // console.log("Y:" + this.yukkuri.moveY);
282 this.isMoving = true;
283 this.yukkuri.reverse();
284 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
285 mangMsg.output(this.yukkuri,EMsg.WALK);
287 this.targetNode = null;
289 // console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
290 this.walk(retryCounter+1);
297 var yukkuri = this.yukkuri;
299 if(yukkuri.isSleeping){
300 if(yukkuri.age%4 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
301 if(yukkuri.param.sleep <= 0){
302 yukkuri.param.sleep = 0;
303 yukkuri.isSleeping = false;
304 mangMsg.output(yukkuri, EMsg.GET_UP);
305 this.status = EAction.THINK;
306 yukkuri.imgBody.tl.resume();
307 yukkuri.imgGroup.tl.resume();
309 yukkuri.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
315 mangMsg.output(this.yukkuri, EMsg.DEAD);
316 this.yukkuri.imgBody.tl.clear();
317 this.yukkuri.imgBody.tl.pause();
318 this.yukkuri.imgGroup.tl.clear();
319 this.yukkuri.imgGroup.tl.pause();
320 this.yukkuri.setBodyImage(EBody.DEAD);
322 eat_start: function(){
325 "targetNode": this.targetNode,
327 "myYukkuri": this.yukkuri
331 unun_start: function(){
334 "myYukkuri": this.yukkuri
337 unun_smell_start: function(){
340 "myYukkuri": this.yukkuri
343 move_to_command: function(){
347 var nodes = ctl.getObjs();
351 for (var key in nodes) {
352 var node = nodes[key];
354 && node instanceof Unun
355 && !(this.targetNode instanceof Unun)
356 && this.yukkuri.within(node, this.yukkuri.getRange() / 2)) {
358 this.targetNode = node;
359 this.setStatus(EAction.UNUN_SMELL_START);
362 else if (node instanceof Food) {
363 if(this.yukkuri.isKuhuku() && this.yukkuri.within(node, this.yukkuri.getRange())){
365 //A yukkuri to go to the food area
366 this.targetNode = node;
367 this.setStatus(EAction.MOVE_TO_EAT_START);
371 //not hunbry or not food.
375 this.status = EAction.WALK;
378 var Event = enchant.Class.create({
379 initialize: function (_data){
381 onactionstart:function(self){
383 if(typeof e === "undefined")return;
386 onactiontick:function(self){
388 if(typeof e === "undefined")return;
391 onactionend:function(self){
393 if(typeof e === "undefined")return;
397 var UnunEvent = enchant.Class.create(Event,{
398 initialize: function (_data){
400 this.yukkuri = _data.myYukkuri;
401 this.action = _data.action;
402 this.action.setStatus(EAction.UNUN_WAIT);
403 mangMsg.output(this.yukkuri, EMsg.UNUN);
404 this.yukkuri.setFaceImage(EFace.HAPPY2);
407 this.yukkuri.wait(sec, {
408 "onactionstart": this.onactionstart(this),
409 "onactiontick": this.onactiontick(this),
410 "onactionend": this.onactionend(this)
413 onactionstart:function(self){
415 if(typeof e === "undefined")return;
418 onactiontick:function(self){
420 if(typeof e === "undefined")return;
423 onactionend:function(self){
425 if(typeof e === "undefined")return;
427 self.action.setStatus(EAction.WAIT);
428 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
430 "waitframe": FPS * 1.5,
431 "action": self.action,
432 "myYukkuri": self.yukkuri
437 var WaitEvent = enchant.Class.create(Event,{
438 initialize: function (_data){
440 this.yukkuri = _data.myYukkuri;
441 this.action = _data.action;
442 this.waitframe = _data.waitframe;
443 this.yukkuri.wait(this.waitframe, {
444 "onactionstart": this.onactionstart(this),
445 "onactiontick": this.onactiontick(this),
446 "onactionend": this.onactionend(this)
449 onactionend:function(self){
451 if(typeof e === "undefined")return;
452 self.action.setStatus(EAction.THINK);
456 var UnunSmellEvent = enchant.Class.create(Event,{
457 initialize: function (_data){
459 this.yukkuri = _data.myYukkuri;
460 this.action = _data.action;
461 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
462 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
463 this.yukkuri.setFaceImage(EFace.CRY1);
465 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
466 this.yukkuri.wait(sec, {
467 "onactionstart": this.onactionstart(this),
468 "onactiontick": this.onactiontick(this),
469 "onactionend": this.onactionend(this)
472 onactionend:function(self){
474 if(typeof e === "undefined")return;
475 self.action.setStatus(EAction.THINK);
480 var EatEvent = enchant.Class.create(Event,{
481 initialize: function (_data){
483 this.yukkuri = _data.myYukkuri;
484 this.food = _data.targetNode;
485 this.action = _data.action;
486 this.action.setStatus(EAction.EAT_WAIT);
487 mangMsg.output(this.yukkuri, EMsg.EAT);
488 this.yukkuri.setFaceImage(EFace.EAT2);
489 // this.yukkuri.image = game.assets[EResPath.MARISA_];
491 // var sec = FPS * (this.yukkuri.param.hungry/10 + 3);
494 this.yukkuri.wait(sec, {
495 "onactionstart": this.onactionstart(this),
496 "onactiontick": this.onactiontick(this),
497 "onactionend": this.onactionend(this)
500 onactionstart:function(self){
502 if(typeof e === "undefined")return;
503 self.yukkuri.eat(self.food);
506 onactiontick:function(self){
508 if(typeof e === "undefined")return;
511 onactionend:function(self){
513 if(typeof e === "undefined")return;
514 if(self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
515 self.action.setStatus(EAction.THINK);
516 self.yukkuri.setFaceImage(EFace.NORMAL);
518 self.action.setStatus(EAction.EAT_START);
525 * -When yukkuri find Food.
528 * targetNode: enchant.Node
532 var MoveToEatEvent = enchant.Class.create(Event,{
533 initialize: function (_data){
535 this.yukkuri = this.data.myYukkuri;
536 this.action = this.data.action;
538 var yukkuri = this.yukkuri;
539 var node = this.data.targetNode;
541 if(this.data.type == "food"){
542 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
543 yukkuri.vx = node.x - yukkuri.getX();
544 yukkuri.vy = node.y - yukkuri.getY();
545 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
546 var frame = distance + distance/5 + 1;
547 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
549 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
550 "onactionstart": this.onactionstart(this),
551 "onactiontick": this.onactiontick(this),
552 "onactionend": this.onactionend(this)
556 onactionstart:function(self){
558 if(typeof e === "undefined")return;
559 self.yukkuri.tweet("ゆゆ??\nたべものさん\nはっけんなのぜ!");
562 onactiontick:function(self){
564 if(typeof e === "undefined")return;
567 onactionend:function(self){
569 if(typeof e === "undefined")return;
570 self.action.setStatus(EAction.EAT_START);
574 var MoveCommandEvent = enchant.Class.create(Event,{
575 initialize: function (_data){
577 this.yukkuri = this.data.myYukkuri;
578 this.action = this.data.action;
579 this.vx = this.data.vx;
580 this.vy = this.data.vy;
582 var yukkuri = this.yukkuri;
583 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
584 yukkuri.vx = node.x - yukkuri.getX();
585 yukkuri.vy = node.y - yukkuri.getY();
586 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
587 var frame = distance + 1;
588 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
589 "onactionstart": this.onactionstart(this),
590 "onactiontick": this.onactiontick(this),
591 "onactionend": this.onactionend(this)
594 onactionstart:function(self){
596 if(typeof e === "undefined")return;
599 onactiontick:function(self){
601 if(typeof e === "undefined")return;
604 onactionend:function(self){
606 if(typeof e === "undefined")return;
607 self.action.setStatus(EAction.THINK);
612 var ObjSprite = enchant.Class.create(enchant.Sprite,{
613 initialize: function (w, h){
614 enchant.Sprite.call(this, w, h);
618 removeAll: function(){
624 var Food = enchant.Class.create(ObjSprite,{
625 initialize: function (type, x, y){
626 this.classname = "Food";
627 ObjSprite.call(this,16,16);
628 this.image = game.assets[EResPath.OBJECT];
632 //一つにつきgiveの値分、hunguryを減少させられる
635 foodGroup.addChild(this);
636 this.addEventListener('enterframe', function(){
637 if(this.amount <= 0){
642 getAmount: function(){
649 var Unun = enchant.Class.create(ObjSprite,{
650 initialize: function (x, y){
651 this.classname = "Unun";
652 ObjSprite.call(this,32,32);
653 this.image = game.assets[EResPath.YUKKURI_UNUN];
656 backgroundMap.addChild(this);
659 var Okazari = enchant.Class.create(enchant.Sprite,{
660 initialize: function(){
661 this.classname = "Okazari";
662 enchant.Sprite.call(this, 64, 64);
663 this.image = game.assets[EResPath.OKAZARI];
664 this.x = -CHARA_WIDTH / 2;
665 this.y = -12 - CHARA_HEIGHT / 2;
668 var Yukkuri = enchant.Class.create(ObjSprite,{
669 initialize: function(x, y){
670 ObjSprite.call(this, 64, 64);
671 this.classname = "Yukkuri";
672 this.imgGroup = new SpriteGroup();
673 this.imgBody = new SpriteGroup();
674 this.imgGroup.id = guid();
675 this.imgBody.id = guid();
676 this.x = -CHARA_WIDTH / 2;
677 this.y = -CHARA_HEIGHT / 2;
680 this.image = game.assets[EResPath.YUKKURI_BASE];
681 this.direction = EDirection.RIGHT;
682 this.addEventListener('enterframe', this.runEnterframe);
683 this.isSleeping = false;
685 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
686 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
688 runEnterframe:function(){
690 if(this.isDead())return;
697 if(this.direction == EDirection.RIGHT){
698 this.imgBody.scaleX = 1;
700 else if(this.direction == EDirection.LEFT){
701 this.imgBody.scaleX = -1;
704 tweet:function(text){
705 this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
707 moveTo:function(x, y, time){
708 this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
710 moveBy:function(x, y, time, eventFunctions){
714 return self.imgGroup.x + x;
717 return self.imgGroup.y + y;
720 easing: enchant.Easing.SIN_EASEINOUT
722 //-Event register [onactionstart,onactiontick,onactionend]
723 if(eventFunctions !== undefined){
724 for(var key in eventFunctions){
725 params[key] = eventFunctions[key];
728 this.imgGroup.tl.tween(params);
731 wait:function(frame, eventFunctions){
732 this.moveBy(0,1,frame,eventFunctions);
737 animation: function(){
738 this.imgBody.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
739 // this.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
740 // this.okazari.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
741 // this.face.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
742 // this.hear.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
744 getWidth: function(){
747 getHeight: function(){
751 return this.imgGroup.x;
754 return this.imgGroup.y;
757 this.imgGroup.x += x;
759 // this.shadow.x += x;
760 // this._tweet.x += x;
763 this.imgGroup.y += y;
765 // this.shadow.y += y;
766 // this._tweet.y += y;
768 // changeFace: function(erespath){
769 // this.face.image = game.assets[erespath];
771 loadParamsXML: function(url){
772 var http = new JKL.ParseXML( url );
775 runYukkuri: function(){
776 if(this.param.hungry > 70){
777 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
778 this.param.yukkuri -= 1;
781 else if(this.param.hungry < 10){
782 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
785 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
786 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
788 runHungry: function(){
789 if(this.age%50 === 0 && this.age !== 0)this.param.hungry++;
790 if(this.param.hungry >= 100)this.param.hungry = 100;
793 if(this.age%50 === 0 && this.age !== 0)this.param.unun++;
794 if(this.param.unun >= 100)this.param.unun = 100;
796 runSleep: function(){
797 if(!this.isSleeping){
798 if(this.age%100 === 0 && this.age !== 0)this.param.sleep++;
799 if(this.param.sleep >= 100){
800 this.param.sleep = 100;
801 this.isSleeping = true;
802 mangMsg.output(this, EMsg.SLEEP);
804 this.imgBody.tl.pause();
805 this.imgGroup.tl.pause();
806 this.imgBody.tl.clear();
807 this.imgGroup.tl.clear();
808 this.face.image = game.assets[EResPath.MARISA_FACE_SLEEP];
814 changeFace: function(){
815 if(this.param.yukkuri >= 80){
816 this.setFaceImage(EFace.HAPPY1);
818 else if(this.param.yukkuri >= 50){
819 this.setFaceImage(EFace.NORMAL);
821 else if(this.param.yukkuri >= 30){
822 this.setFaceImage(EFace.TIRED);
824 else if(this.param.yukkuri >= 10){
825 this.setFaceImage(EFace.CRY1);
827 else if(this.param.yukkuri >= 1){
828 this.setFaceImage(EFace.CRY2);
831 getRange: function(){
832 return this.param.range;
835 return this.isSleeping;
838 return this.param.yukkuri <= 0;
840 isManpuku: function(){
841 return this.param.hungry <= 20;
843 isKuhuku: function(){
844 return this.param.hungry >= 40;
846 getYukkuri: function(){
847 return this.param.yukkuri;
849 setYukkuri: function(yukkuri){
850 this.param.yukkuri = yukkuri;
851 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
853 getHungry: function(){
854 return this.param.hungry;
856 setHungry: function(hungry){
857 this.param.hungry = hungry;
858 if(this.param.hungry < 0)this.param.hungry = 0;
861 return this.param.unun;
863 setUnun: function(unun){
864 this.param.unun = unun;
865 if(this.param.unun < 0)this.param.unun = 0;
870 this.setHungry(this.param.hungry - food.getGive());
871 this.setUnun(this.getUnun() + food.getGive() / 4);
872 this.setYukkuri(this.getYukkuri() + 5);
875 if(this.direction == EDirection.RIGHT){
876 new Unun(this.getX(), this.getY() + this.getHeight()/5 );
878 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
882 setBodyImage: function(ebody){
883 var path = this.bodyStatus[ebody];
884 this.image = game.assets[path];
886 destruct: function(){
890 var Marisa = enchant.Class.create(Yukkuri,{
891 initialize: function(x, y){
892 Yukkuri.call(this,x,y);
893 this.classname = "Marisa";
896 // var xml = this.loadParamsXML("./data/marisa/params.xml");
897 var json = net.load("./data/marisa/params.json");
898 this.param = json.root.param;
899 this.shadow = new enchant.Sprite(64, 64);
900 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
901 this.shadow.x = 0 + this.x;
902 this.shadow.y = CHARA_HEIGHT / 16 + this.x;
903 this.shadow.image._element.style.zIndex = 2;
905 this._style.zIndex = 5;
907 this.face = new enchant.Sprite(64, 64);
908 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
909 this.face.x = -CHARA_WIDTH / 2;
910 this.face.y = -CHARA_HEIGHT / 2;
911 this.face._style.zIndex = 0;
914 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
915 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
916 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
917 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
918 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
919 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
920 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
921 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
922 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
923 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
926 this.hear = new enchant.Sprite(64, 64);
927 this.hear.image = game.assets[EResPath.MARISA_HEAR];
928 this.hear.x = -CHARA_WIDTH / 2;
929 this.hear.y = -CHARA_HEIGHT / 2;
930 this.hear._style.zIndex = 0;
932 this.okazari = new Okazari();
933 this.okazari.image._element.style.zIndex = 1;
935 // this.imgGroup._style.zIndex = 1;
937 this.imgGroup.addChild(this.shadow);
938 this.imgBody.addChild(this);
939 this.imgBody.addChild(this.face);
940 this.imgBody.addChild(this.hear);
941 this.imgBody.addChild(this.okazari);
942 this.imgGroup.addChild(this.imgBody);
943 backgroundMap.addChild(this.imgGroup);
944 this._tweet = new TTweet(148, 64);
945 this._tweet.image._element.style.zIndex = 20;
947 this.imgGroup.addChild(this._tweet);
951 this.action = new Action(this);
955 setFaceImage: function(eface){
956 var path = this.faceStatus[eface];
957 this.face.image = game.assets[path];
960 var Player = enchant.Class.create(Marisa,{
961 initialize: function(x, y){
962 // this.runEnterframe = function(){
964 Marisa.call(this, x, y);
965 this.classname = "Player";
967 // this.removeEventListener('enterframe',this.runEnterframe);
968 this.addEventListener('enterframe', function(){
969 if(this.age%10 === 0 && this.age !== 0){
970 // console.log("palyer:" + this.age);
974 ///////////////////////////////////////////////
975 //Action pattern for debug
977 // this.changeFace(EResPath.MARISA_FACE_TIRED);
979 this.direction = EDirection.LEFT;
981 if(game.input.right){
983 this.direction = EDirection.RIGHT;
987 this.tweet("ゆっくりしていってね!");
992 ///////////////////////////////////////////////
994 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
995 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
997 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
999 //- Display the circle of search range.
1000 // fieldBg.image.clear();
1001 // fieldBg.image.context.beginPath();
1002 // fieldBg.image.context.fillStyle = '#ff0000';
1003 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
1004 // fieldBg.image.context.fill();
1008 game.onload = function(){
1010 mangTouch = new MangTouch(ctl);
1011 mangMsg = new MangMsg(ctl);
1012 ctl.setDefined(def);
1013 backgroundMap.image = game.assets[EResPath.MAP0];
1014 backgroundMap.loadData(_mapData);
1015 backgroundMap.collisionData = _collisionData;
1017 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
1018 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
1019 fieldBg.image = fieldSurface;
1023 menuSurface.context.fillStyle = '#000';
1024 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
1025 menuBg.image = menuSurface;
1026 menuBg.x = EMenuPos.X;
1027 menuBg.y = EMenuPos.Y;
1029 backgroundMap.addChild(fieldBg);
1030 mangIcon = new MangIcon(ctl, menuBg);
1032 game.rootScene.addChild(backgroundMap);
1033 game.rootScene.addChild(menuBg);
1035 // var labelGroup = new LabelGroup();
1036 mangLabel = new MangLabel(ctl, menuBg);
1037 // var info = new Label("ゆっくり");
1038 // info.color = "#ffffff";
1039 // info.font = "14px 'Times New Roman'";
1041 // info.y = GAME_HEIGHT / 2;
1042 // labelGroup.addChild(info);
1043 // menuBg.addChild(labelGroup);
1046 // var food = new def.Food("apple", 200, 250);
1047 backgroundMap.addChild(foodGroup);
1048 var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
1049 new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y);
1052 game.rootScene.addEventListener('touchstart', function (e) {
1053 game.touched = true;
1054 var mang = mangTouch.get(ctl.getCurrentCommand());
1057 game.rootScene.addEventListener('touchmove', function (e) {
1058 var mang = mangTouch.get(ctl.getCurrentCommand());
1061 game.rootScene.addEventListener('touchend', function (e) {
1062 var mang = mangTouch.get(ctl.getCurrentCommand());
1064 game.touched = false;
1068 game.rootScene.addEventListener('enterframe', function(){
1070 mangLabel.draw(player);
1073 this.addEventListener('enterframe', function(){
1074 //The priority processing of display instead of z-index
1075 backgroundMap.childNodes.sort(
1077 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
1080 else if(typeof a.id === "undefined"){
1083 else if(typeof b.id === "undefined"){
1086 if(a.y < b.y)return -1;
1087 if(a.y > b.y)return 1;