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;
25 YUKKURI_BASE : './data/yukkuri_base.png',
26 YUKKURI_BODY_DEAD : './data/yukkuri_dead.png',
27 YUKKURI_UNUN : './data/unun.png',
28 YUKKURI_SHADOW : './data/shadow.png',
29 MARISA_FACE_NORMAL : './data/marisa/face_normal1.png',
30 MARISA_FACE_TIRED : './data/marisa/face_tired1.png',
31 MARISA_FACE_ANGRY : './data/marisa/face_angry1.png',
32 MARISA_FACE_CRY1 : './data/marisa/face_cry1.png',
33 MARISA_FACE_CRY2 : './data/marisa/face_cry2.png',
34 MARISA_FACE_EAT1 : './data/marisa/face_eat1.png',
35 MARISA_FACE_EAT2 : './data/marisa/face_eat2.png',
36 MARISA_FACE_HAPPY1 : './data/marisa/face_happy1.png',
37 MARISA_FACE_HAPPY2 : './data/marisa/face_happy2.png',
38 MARISA_FACE_SLEEP : './data/marisa/face_sleep1.png',
39 MARISA_HEAR : './data/marisa/hear1.png',
40 OBJECT : './data/object.png',
41 MAP0 : './data/map0.png',
42 COMMAND : './data/command.png',
43 OKAZARI : './data/okazari.png',
77 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
88 MOVE_TO_EAT_START: 10,
89 MOVE_TO_EAT_UNDERWAY: 11,
93 UNUN_SMELL_START : 15,
114 include("./lang/ja.js");
115 window.onload = function(){
118 var def = new Object();
119 var foodGroup = new Group();
120 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
121 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
122 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
123 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
124 var game = new Game(GAME_WIDTH, GAME_HEIGHT);
128 for(var _v in EResPath){
129 _loadArr[i] = EResPath[_v];
132 game.preload(_loadArr);
133 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
134 var backgroundMap = new MapGroup(16, 16);
135 include("./class.js");
136 include("./ctrl.js");
139 ctl.setBackgroundMap(backgroundMap);
140 var Action = enchant.Class.create({
141 initialize: function (yukkuri){
142 this.status = EAction.THINK;
143 this.yukkuri = yukkuri;
144 this.isMoving = false;
145 this.targetNode = null;
147 getStatus: function(){
150 setStatus: function(eaction){
151 this.status = eaction;
154 if(this.yukkuri.isDead()){
155 this.status = EAction.DEAD;
157 // else if(this.yukkuri.isSleep()){
158 // this.status = EAction.SLEEP;
169 if(this.yukkuri.age%2 === 0){
170 if(this.yukkuri.isSleep()){
171 this.setStatus(EAction.SLEEP_START);
173 else if(this.yukkuri.getUnun() >= 80){
174 this.setStatus(EAction.UNUN_START);
176 // this.yukkuri.param.yukkuri -= 1;
177 this.yukkuri.changeFace();
183 case EAction.MOVE_TO_EAT_START:
184 this.move_to_eat_start();
186 case EAction.MOVE_TO_EAT_UNDERWAY:
192 case EAction.SLEEP_START:
195 case EAction.SLEEP_WAIT:
200 case EAction.EAT_START:
203 case EAction.EAT_WAIT:
205 case EAction.UNUN_START:
208 case EAction.UNUN_WAIT:
210 case EAction.MOVE_TO_COMMAND:
211 this.move_to_command();
213 case EAction.UNUN_SMELL_START:
214 this.unun_smell_start();
219 move_to_eat_start : function(){
222 "targetNode": this.targetNode,
224 "myYukkuri": this.yukkuri
230 walk : function(retryCounter){
231 if(retryCounter > 15){
233 this.status = EAction.NONE;
234 console.log("retryCount over");
237 if(this.yukkuri.imgGroup.tl.queue.length === 0){
240 this.isMoving = false;
241 this.status = EAction.THINK;
245 var xpos = 150 + rand(40) - (retryCounter * 10);
246 var ypos = 150 + rand(40) - (retryCounter * 10);
249 this.yukkuri.vy = -ypos;
251 else if(rand(8) == 1){
252 this.yukkuri.vx = xpos;
253 this.yukkuri.vy = -ypos;
254 this.yukkuri.direction = EDirection.RIGHT;
256 else if(rand(8) == 2){
257 this.yukkuri.vx = xpos;
259 this.yukkuri.direction = EDirection.RIGHT;
261 else if(rand(8) == 3){
262 this.yukkuri.vx = xpos;
263 this.yukkuri.vy = ypos;
264 this.yukkuri.direction = EDirection.RIGHT;
266 else if(rand(8) == 4){
268 this.yukkuri.vy = ypos;
270 else if(rand(8) == 5){
271 this.yukkuri.vx = -xpos;
272 this.yukkuri.vy = ypos;
273 this.yukkuri.direction = EDirection.LEFT;
275 else if(rand(8) == 6){
276 this.yukkuri.vx = -xpos;
278 this.yukkuri.direction = EDirection.LEFT;
280 else if(rand(8) == 7){
281 this.yukkuri.vx = -xpos;
282 this.yukkuri.vy = -ypos;
283 this.yukkuri.direction = EDirection.LEFT;
285 if (this.yukkuri.vx || this.yukkuri.vy) {
286 var map = ctl.backgroundMap;
287 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
288 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
289 var x = this.yukkuri.imgGroup.x + this.yukkuri.vx;
290 var y = this.yukkuri.imgGroup.y + this.yukkuri.vy + this.yukkuri.height / 2;
291 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
292 // console.log("あたってないよ:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
293 // console.log("X:" + this.yukkuri.moveX);
294 // console.log("Y:" + this.yukkuri.moveY);
295 this.isMoving = true;
296 this.yukkuri.reverse();
297 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
298 mangMsg.output(this.yukkuri,EMsg.WALK);
300 this.targetNode = null;
302 // console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
303 this.walk(retryCounter+1);
309 sleep_start: function(){
312 "myYukkuri": this.yukkuri
317 mangMsg.output(this.yukkuri, EMsg.DEAD);
318 this.yukkuri.imgBody.tl.clear();
319 this.yukkuri.imgBody.tl.pause();
320 this.yukkuri.imgGroup.tl.clear();
321 this.yukkuri.imgGroup.tl.pause();
322 this.yukkuri.setBodyImage(EBody.DEAD);
324 eat_start: function(){
327 "targetNode": this.targetNode,
329 "myYukkuri": this.yukkuri
333 unun_start: function(){
336 "myYukkuri": this.yukkuri
339 unun_smell_start: function(){
342 "myYukkuri": this.yukkuri
345 move_to_command: function(){
349 var nodes = ctl.getObjs();
353 for (var key in nodes) {
354 var node = nodes[key];
356 && node instanceof Unun
357 && !(this.targetNode instanceof Unun)
358 && this.yukkuri.within(node, this.yukkuri.getRange() / 2)) {
360 this.targetNode = node;
361 this.setStatus(EAction.UNUN_SMELL_START);
364 else if (node instanceof Food) {
365 if(this.yukkuri.isKuhuku() && this.yukkuri.within(node, this.yukkuri.getRange())){
367 //A yukkuri to go to the food area
368 this.targetNode = node;
369 this.setStatus(EAction.MOVE_TO_EAT_START);
373 //not hunbry or not food.
377 this.status = EAction.WALK;
380 var Event = enchant.Class.create({
381 initialize: function (_data){
383 onactionstart:function(self){
385 if(typeof e === "undefined")return;
388 onactiontick:function(self){
390 if(typeof e === "undefined")return;
393 onactionend:function(self){
395 if(typeof e === "undefined")return;
399 var WalkEvent = enchant.Class.create(Event,{
400 initialize: function (_data){
402 this.yukkuri = _data.myYukkuri;
403 this.action = _data.action;
405 mangMsg.output(this.yukkuri, EMsg.SLEEP);
406 this.action.setStatus(EAction.SLEEP_WAIT);
407 this.yukkuri.setFaceImage(EFace.SLEEP);
408 this.yukkuri.tlPause();
410 this.yukkuri.addEventListener('enterframe', function() {
411 var yukkuri = self.yukkuri;
419 var SleepEvent = enchant.Class.create(Event,{
420 initialize: function (_data){
422 this.yukkuri = _data.myYukkuri;
423 this.action = _data.action;
425 mangMsg.output(this.yukkuri, EMsg.SLEEP);
426 this.action.setStatus(EAction.SLEEP_WAIT);
427 this.yukkuri.setFaceImage(EFace.SLEEP);
428 this.yukkuri.tlPause();
431 this.yukkuri.addEventListener('enterframe', function() {
432 var yukkuri = self.yukkuri;
433 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
434 if(yukkuri.param.sleep <= 0){
435 yukkuri.param.sleep = 0;
436 this.removeEventListener("enterframe",arguments.callee);
437 mangMsg.output(self.yukkuri, EMsg.GET_UP);
438 yukkuri.setFaceImage(EFace.NORMAL);
440 // self.action.setStatus(EAction.WAIT);
441 self.action.setStatus(EAction.THINK);
447 var UnunEvent = enchant.Class.create(Event,{
448 initialize: function (_data){
450 this.yukkuri = _data.myYukkuri;
451 this.action = _data.action;
452 this.action.setStatus(EAction.UNUN_WAIT);
453 mangMsg.output(this.yukkuri, EMsg.UNUN);
454 this.yukkuri.setFaceImage(EFace.HAPPY2);
457 this.yukkuri.wait(sec, {
458 "onactionstart": this.onactionstart(this),
459 "onactiontick": this.onactiontick(this),
460 "onactionend": this.onactionend(this)
463 onactionstart:function(self){
465 if(typeof e === "undefined")return;
468 onactiontick:function(self){
470 if(typeof e === "undefined")return;
473 onactionend:function(self){
475 if(typeof e === "undefined")return;
477 self.action.setStatus(EAction.WAIT);
478 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
480 "waitframe": FPS * 1.5,
481 "action": self.action,
482 "myYukkuri": self.yukkuri
487 var WaitEvent = enchant.Class.create(Event,{
488 initialize: function (_data){
490 this.yukkuri = _data.myYukkuri;
491 this.action = _data.action;
492 this.waitframe = _data.waitframe;
493 this.yukkuri.wait(this.waitframe, {
494 "onactionstart": this.onactionstart(this),
495 "onactiontick": this.onactiontick(this),
496 "onactionend": this.onactionend(this)
499 onactionend:function(self){
501 if(typeof e === "undefined")return;
502 self.action.setStatus(EAction.THINK);
506 var UnunSmellEvent = enchant.Class.create(Event,{
507 initialize: function (_data){
509 this.yukkuri = _data.myYukkuri;
510 this.action = _data.action;
511 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
512 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
513 this.yukkuri.setFaceImage(EFace.CRY1);
515 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
516 this.yukkuri.wait(sec, {
517 "onactionstart": this.onactionstart(this),
518 "onactiontick": this.onactiontick(this),
519 "onactionend": this.onactionend(this)
522 onactionend:function(self){
524 if(typeof e === "undefined")return;
525 self.action.setStatus(EAction.THINK);
530 var EatEvent = enchant.Class.create(Event,{
531 initialize: function (_data){
533 this.yukkuri = _data.myYukkuri;
534 this.food = _data.targetNode;
535 this.action = _data.action;
536 this.action.setStatus(EAction.EAT_WAIT);
537 mangMsg.output(this.yukkuri, EMsg.EAT);
538 this.yukkuri.setFaceImage(EFace.EAT2);
540 // var sec = FPS * (this.yukkuri.param.hungry/10 + 3);
543 this.yukkuri.wait(sec, {
544 "onactionstart": this.onactionstart(this),
545 "onactiontick": this.onactiontick(this),
546 "onactionend": this.onactionend(this)
549 onactionstart:function(self){
551 if(typeof e === "undefined")return;
552 self.yukkuri.eat(self.food);
555 onactiontick:function(self){
557 if(typeof e === "undefined")return;
560 onactionend:function(self){
562 if(typeof e === "undefined")return;
563 if(self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
564 self.action.setStatus(EAction.THINK);
565 self.yukkuri.setFaceImage(EFace.NORMAL);
567 self.action.setStatus(EAction.EAT_START);
574 * -When yukkuri find Food.
577 * targetNode: enchant.Node
581 var MoveToEatEvent = enchant.Class.create(Event,{
582 initialize: function (_data){
584 this.yukkuri = this.data.myYukkuri;
585 this.action = this.data.action;
587 var yukkuri = this.yukkuri;
588 var node = this.data.targetNode;
590 if(this.data.type == "food"){
591 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
592 yukkuri.vx = node.x - yukkuri.getX();
593 yukkuri.vy = node.y - yukkuri.getY();
594 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
595 var frame = distance + distance/5 + 1;
596 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
598 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
599 "onactionstart": this.onactionstart(this),
600 "onactiontick": this.onactiontick(this),
601 "onactionend": this.onactionend(this)
605 onactionstart:function(self){
607 if(typeof e === "undefined")return;
608 self.yukkuri.tweet("ゆゆ??\nたべものさん\nはっけんなのぜ!");
611 onactiontick:function(self){
613 if(typeof e === "undefined")return;
616 onactionend:function(self){
618 if(typeof e === "undefined")return;
619 self.action.setStatus(EAction.EAT_START);
623 var MoveCommandEvent = enchant.Class.create(Event,{
624 initialize: function (_data){
626 this.yukkuri = this.data.myYukkuri;
627 this.action = this.data.action;
628 this.vx = this.data.vx;
629 this.vy = this.data.vy;
631 var yukkuri = this.yukkuri;
632 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
633 yukkuri.vx = node.x - yukkuri.getX();
634 yukkuri.vy = node.y - yukkuri.getY();
635 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
636 var frame = distance + 1;
637 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
638 "onactionstart": this.onactionstart(this),
639 "onactiontick": this.onactiontick(this),
640 "onactionend": this.onactionend(this)
643 onactionstart:function(self){
645 if(typeof e === "undefined")return;
648 onactiontick:function(self){
650 if(typeof e === "undefined")return;
653 onactionend:function(self){
655 if(typeof e === "undefined")return;
656 self.action.setStatus(EAction.THINK);
661 var ObjSprite = enchant.Class.create(enchant.Sprite,{
662 initialize: function (w, h){
663 enchant.Sprite.call(this, w, h);
667 removeAll: function(){
673 var Food = enchant.Class.create(ObjSprite,{
674 initialize: function (type, x, y){
675 this.classname = "Food";
676 ObjSprite.call(this,16,16);
677 this.image = game.assets[EResPath.OBJECT];
681 //一つにつきgiveの値分、hunguryを減少させられる
684 foodGroup.addChild(this);
685 this.addEventListener('enterframe', function(){
686 if(this.amount <= 0){
691 getAmount: function(){
698 var Unun = enchant.Class.create(ObjSprite,{
699 initialize: function (x, y){
700 this.classname = "Unun";
701 ObjSprite.call(this,32,32);
702 this.image = game.assets[EResPath.YUKKURI_UNUN];
705 backgroundMap.addChild(this);
708 var Okazari = enchant.Class.create(enchant.Sprite,{
709 initialize: function(){
710 this.classname = "Okazari";
711 enchant.Sprite.call(this, 64, 64);
712 this.image = game.assets[EResPath.OKAZARI];
713 this.x = -CHARA_WIDTH / 2;
714 this.y = -12 - CHARA_HEIGHT / 2;
717 var Yukkuri = enchant.Class.create(ObjSprite,{
718 initialize: function(x, y){
719 ObjSprite.call(this, 64, 64);
720 this.classname = "Yukkuri";
721 this.imgGroup = new SpriteGroup();
722 this.imgBody = new SpriteGroup();
723 this.imgGroup.id = guid();
724 this.imgBody.id = guid();
725 this.x = -CHARA_WIDTH / 2;
726 this.y = -CHARA_HEIGHT / 2;
729 this.image = game.assets[EResPath.YUKKURI_BASE];
730 this.direction = EDirection.RIGHT;
731 this.addEventListener('enterframe', this.runEnterframe);
733 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
734 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
736 runEnterframe:function(){
738 if(this.isDead())return;
745 if(this.direction == EDirection.RIGHT){
746 this.imgBody.scaleX = 1;
748 else if(this.direction == EDirection.LEFT){
749 this.imgBody.scaleX = -1;
752 tweet:function(text){
753 this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
755 moveTo:function(x, y, time){
756 this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
758 moveBy:function(x, y, time, eventFunctions){
762 return self.imgGroup.x + x;
765 return self.imgGroup.y + y;
768 easing: enchant.Easing.SIN_EASEINOUT
770 //-Event register [onactionstart,onactiontick,onactionend]
771 if(eventFunctions !== undefined){
772 for(var key in eventFunctions){
773 params[key] = eventFunctions[key];
776 this.imgGroup.tl.tween(params);
779 wait:function(frame, eventFunctions){
780 this.moveBy(0,1,frame,eventFunctions);
785 animation: function(){
786 this.imgBody.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
787 // this.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
788 // this.okazari.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
789 // this.face.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
790 // this.hear.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
792 getWidth: function(){
795 getHeight: function(){
799 return this.imgGroup.x;
802 return this.imgGroup.y;
805 this.imgGroup.x += x;
807 // this.shadow.x += x;
808 // this._tweet.x += x;
811 this.imgGroup.y += y;
813 // this.shadow.y += y;
814 // this._tweet.y += y;
816 // changeFace: function(erespath){
817 // this.face.image = game.assets[erespath];
819 loadParamsXML: function(url){
820 var http = new JKL.ParseXML( url );
823 runYukkuri: function(){
824 if(this.param.hungry > 70){
825 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
826 this.param.yukkuri -= 1;
829 else if(this.param.hungry < 10){
830 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
833 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
834 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
836 runHungry: function(){
837 if(this.age%50 === 0 && this.age !== 0)this.param.hungry++;
838 if(this.param.hungry >= 100)this.param.hungry = 100;
841 if(this.age%50 === 0 && this.age !== 0)this.param.unun++;
842 if(this.param.unun >= 100)this.param.unun = 100;
844 runSleep: function(){
845 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
846 if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
847 if(this.param.sleep >= 100){
848 this.param.sleep = 100;
852 changeFace: function(){
853 if(this.param.yukkuri >= 80){
854 this.setFaceImage(EFace.HAPPY1);
856 else if(this.param.yukkuri >= 50){
857 this.setFaceImage(EFace.NORMAL);
859 else if(this.param.yukkuri >= 30){
860 this.setFaceImage(EFace.TIRED);
862 else if(this.param.yukkuri >= 10){
863 this.setFaceImage(EFace.CRY1);
865 else if(this.param.yukkuri >= 1){
866 this.setFaceImage(EFace.CRY2);
869 getRange: function(){
870 return this.param.range;
873 return this.param.sleep >= 100;
876 return this.param.yukkuri <= 0;
878 isManpuku: function(){
879 return this.param.hungry <= 20;
881 isKuhuku: function(){
882 return this.param.hungry >= 40;
884 getYukkuri: function(){
885 return this.param.yukkuri;
887 setYukkuri: function(yukkuri){
888 this.param.yukkuri = yukkuri;
889 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
891 getHungry: function(){
892 return this.param.hungry;
894 setHungry: function(hungry){
895 this.param.hungry = hungry;
896 if(this.param.hungry < 0)this.param.hungry = 0;
899 return this.param.unun;
901 setUnun: function(unun){
902 this.param.unun = unun;
903 if(this.param.unun < 0)this.param.unun = 0;
908 this.setHungry(this.param.hungry - food.getGive());
909 this.setUnun(this.getUnun() + food.getGive() / 4);
910 this.setYukkuri(this.getYukkuri() + 5);
913 if(this.direction == EDirection.RIGHT){
914 new Unun(this.getX(), this.getY() + this.getHeight()/5 );
916 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
920 setBodyImage: function(ebody){
921 var path = this.bodyStatus[ebody];
922 this.image = game.assets[path];
925 this.imgBody.tl.pause();
926 this.imgGroup.tl.pause();
927 this.imgBody.tl.clear();
928 this.imgGroup.tl.clear();
930 tlResume: function(){
931 this.imgBody.tl.resume();
932 this.imgGroup.tl.resume();
935 destruct: function(){
939 var Marisa = enchant.Class.create(Yukkuri,{
940 initialize: function(x, y){
941 Yukkuri.call(this,x,y);
942 this.classname = "Marisa";
945 // var xml = this.loadParamsXML("./data/marisa/params.xml");
946 var json = net.load("./data/marisa/params.json");
947 this.param = json.root.param;
948 this.shadow = new enchant.Sprite(64, 64);
949 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
950 this.shadow.x = 0 + this.x;
951 this.shadow.y = CHARA_HEIGHT / 16 + this.x;
952 this.shadow.image._element.style.zIndex = 2;
954 this._style.zIndex = 5;
956 this.face = new enchant.Sprite(64, 64);
957 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
958 this.face.x = -CHARA_WIDTH / 2;
959 this.face.y = -CHARA_HEIGHT / 2;
960 this.face._style.zIndex = 0;
963 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
964 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
965 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
966 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
967 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
968 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
969 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
970 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
971 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
972 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
975 this.hear = new enchant.Sprite(64, 64);
976 this.hear.image = game.assets[EResPath.MARISA_HEAR];
977 this.hear.x = -CHARA_WIDTH / 2;
978 this.hear.y = -CHARA_HEIGHT / 2;
979 this.hear._style.zIndex = 0;
981 this.okazari = new Okazari();
982 this.okazari.image._element.style.zIndex = 1;
984 // this.imgGroup._style.zIndex = 1;
986 this.imgGroup.addChild(this.shadow);
987 this.imgBody.addChild(this);
988 this.imgBody.addChild(this.face);
989 this.imgBody.addChild(this.hear);
990 this.imgBody.addChild(this.okazari);
991 this.imgGroup.addChild(this.imgBody);
992 backgroundMap.addChild(this.imgGroup);
993 this._tweet = new TTweet(148, 64);
994 this._tweet.image._element.style.zIndex = 20;
996 this.imgGroup.addChild(this._tweet);
1000 this.action = new Action(this);
1004 setFaceImage: function(eface){
1005 var path = this.faceStatus[eface];
1006 this.face.image = game.assets[path];
1009 var Player = enchant.Class.create(Marisa,{
1010 initialize: function(x, y){
1011 // this.runEnterframe = function(){
1013 Marisa.call(this, x, y);
1014 this.classname = "Player";
1015 ctl.setPlayer(this);
1016 // this.removeEventListener('enterframe',this.runEnterframe);
1017 this.addEventListener('enterframe', function(){
1018 if(this.age%10 === 0 && this.age !== 0){
1019 // console.log("palyer:" + this.age);
1022 ///////////////////////////////////////////////
1023 //Action pattern for debug
1024 if(game.input.left){
1025 // this.changeFace(EResPath.MARISA_FACE_TIRED);
1027 this.direction = EDirection.LEFT;
1029 if(game.input.right){
1031 this.direction = EDirection.RIGHT;
1035 this.tweet("ゆっくりしていってね!");
1038 if(game.input.down){
1041 ///////////////////////////////////////////////
1043 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
1044 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
1046 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
1048 //- Display the circle of search range.
1049 // fieldBg.image.clear();
1050 // fieldBg.image.context.beginPath();
1051 // fieldBg.image.context.fillStyle = '#ff0000';
1052 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
1053 // fieldBg.image.context.fill();
1057 game.onload = function(){
1059 mangTouch = new MangTouch(ctl);
1060 mangMsg = new MangMsg(ctl);
1061 ctl.setDefined(def);
1062 backgroundMap.image = game.assets[EResPath.MAP0];
1063 backgroundMap.loadData(_mapData);
1064 backgroundMap.collisionData = _collisionData;
1066 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
1067 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
1068 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
1069 fieldBg.image = fieldSurface;
1073 windowFront.image = windowSurface;
1076 windowFront.opacity = 0.5;
1078 windowSurface.context.fillStyle = '#000';
1079 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
1082 menuSurface.context.fillStyle = '#000';
1083 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
1084 menuBg.image = menuSurface;
1085 menuBg.x = EMenuPos.X;
1086 menuBg.y = EMenuPos.Y;
1087 backgroundMap.addChild(fieldBg);
1088 mangIcon = new MangIcon(ctl, menuBg);
1090 game.rootScene.addChild(backgroundMap);
1091 game.rootScene.addChild(windowFront);
1092 game.rootScene.addChild(menuBg);
1094 // var labelGroup = new LabelGroup();
1095 mangLabel = new MangLabel(ctl, menuBg);
1096 // var info = new Label("ゆっくり");
1097 // info.color = "#ffffff";
1098 // info.font = "14px 'Times New Roman'";
1100 // info.y = GAME_HEIGHT / 2;
1101 // labelGroup.addChild(info);
1102 // menuBg.addChild(labelGroup);
1105 // var food = new def.Food("apple", 200, 250);
1106 backgroundMap.addChild(foodGroup);
1107 var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
1108 new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y);
1111 game.rootScene.addEventListener('touchstart', function (e) {
1112 game.touched = true;
1113 var mang = mangTouch.get(ctl.getCurrentCommand());
1116 game.rootScene.addEventListener('touchmove', function (e) {
1117 var mang = mangTouch.get(ctl.getCurrentCommand());
1120 game.rootScene.addEventListener('touchend', function (e) {
1121 var mang = mangTouch.get(ctl.getCurrentCommand());
1123 game.touched = false;
1127 game.rootScene.addEventListener('enterframe', function(){
1129 mangLabel.draw(player);
1132 this.addEventListener('enterframe', function(){
1133 //The priority processing of display instead of z-index
1134 backgroundMap.childNodes.sort(
1136 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
1139 else if(typeof a.id === "undefined"){
1142 else if(typeof b.id === "undefined"){
1145 if(a.y < b.y)return -1;
1146 if(a.y > b.y)return 1;