2 //////////////////////////////////////
4 CanvasLayer初期化後にcanvasのコンテキストを操作する
6 // var initCanvas = CanvasLayer.prototype.initialize;
8 // CanvasLayer.prototype.initialize = function() {
9 // initCanvas.call(this);
10 // console.log("canvas");
12 // // 拡大時の処理をNearest Neighbor方式に切り替え
13 // // ただしChromeとFireFoxでのみ動作
14 // this.context.imageSmoothingEnabled = false;
15 // this.context.webkitImageSmoothingEnabled = false;
16 // this.context.mozImageSmoothingEnabled = false;
24 var LabelGroup = enchant.Class.mixClasses(Label, Group,true);
26 //////////////////////////////////////
28 //////////////////////////////////////
29 var PALYER_INIT_X = 100;
30 var PALYER_INIT_Y = 100;
32 var CHARA_HEIGHT = 64;
34 var GAME_HEIGHT = 600;
41 // var DAY = HOUR * 24;
43 var GAME_START_TIME = HOUR * 6;
49 YUKKURI_BASE : './data/yukkuri_base.png',
50 YUKKURI_BODY_DEAD : './data/yukkuri_dead.png',
51 YUKKURI_UNUN : './data/unun.png',
52 YUKKURI_SHADOW : './data/shadow.png',
53 MARISA_FACE_NORMAL : './data/marisa/face_normal1.png',
54 MARISA_FACE_TIRED : './data/marisa/face_tired1.png',
55 MARISA_FACE_ANGRY : './data/marisa/face_angry1.png',
56 MARISA_FACE_CRY1 : './data/marisa/face_cry1.png',
57 MARISA_FACE_CRY2 : './data/marisa/face_cry2.png',
58 MARISA_FACE_EAT1 : './data/marisa/face_eat1.png',
59 MARISA_FACE_EAT2 : './data/marisa/face_eat2.png',
60 MARISA_FACE_HAPPY1 : './data/marisa/face_happy1.png',
61 MARISA_FACE_HAPPY2 : './data/marisa/face_happy2.png',
62 MARISA_FACE_SLEEP : './data/marisa/face_sleep1.png',
63 MARISA_HEAR : './data/marisa/hear1.png',
64 MARISA_OKAZARI : './data/marisa/okazari.png',
65 OBJECT : './data/object.png',
66 MAP0 : './data/map0.png',
67 COMMAND : './data/command.png',
68 PLACE_TREE : './data/system/place_tree.png',
69 GRASS : './data/system/grass.png',
70 PLAYER_BADGE : './data/system/player_badge.png',
71 // PLACE_TREE : './data/system/rapture.png',
77 FACE_NORMAL : './data/reimu/face_normal1.png',
78 FACE_TIRED : './data/reimu/face_tired1.png',
79 FACE_ANGRY : './data/reimu/face_angry1.png',
80 FACE_CRY1 : './data/reimu/face_cry1.png',
81 FACE_CRY2 : './data/reimu/face_cry2.png',
82 FACE_EAT1 : './data/reimu/face_eat1.png',
83 FACE_EAT2 : './data/reimu/face_eat2.png',
84 FACE_HAPPY1 : './data/reimu/face_happy1.png',
85 FACE_HAPPY2 : './data/reimu/face_happy2.png',
86 FACE_SLEEP : './data/reimu/face_sleep1.png',
87 HEAR : './data/reimu/hear1.png',
88 OKAZARI : './data/reimu/okazari.png',
89 SUB1 : './data/reimu/sub1.png',
121 HEIGHT : GAME_HEIGHT,
127 WIDTH: GAME_WIDTH - EMenuPos.WIDTH,
138 MOVE_TO_EAT_START: 10,
139 MOVE_TO_EAT_UNDERWAY: 11,
143 UNUN_SMELL_START : 15,
144 UNUN_SMELL_WAIT : 16,
147 COMMUNICATE_START : 19,
148 COMMUNICATE_WAIT: 20,
149 COMMUNICATE_RECV: 21,
150 MOVE_TO_PLACE_START_HOMELESS: 22,
151 MOVE_TO_PLACE_HOMELESS_UNDERWAY: 23,
152 DECLARE_PLACE_HOMELESS: 24,
153 MOVE_TO_HUNT_START: 25,
186 LEARN_NO_FOOD_IN_PLACE:19,
188 var EWalkAnimation = {
218 NO_FOOD_IN_PLACE : 1,
224 var ObjSprite = enchant.Class.create(enchant.Sprite,{
225 initialize: function (w, h){
226 enchant.Sprite.call(this, w, h);
229 // // new BoxLabel(this.ctl,100, e.x, e.y);
230 // var box = new Box(this.ctl, 200, 200);
231 // box.text("テスト\naaaaaa\nfffffffff\nテスト\naaaaaa\nfffffffff\nテスト\naaaaaa\n", e.x, e.y);
233 getStatusForDisplay: function (){
242 getWidth: function(){
245 getHeight: function(){
248 removeAll: function(){
255 enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
266 //-Event register [onactionstart,onactiontick,onactionend]
267 if(eventFunctions !== undefined){
268 for(var key in eventFunctions){
269 params[key] = eventFunctions[key];
272 return this.tween(params);
274 function plusFrameScale(frame, scale){
275 return (frame/2) * (1 - scale)
280 include("./lang/ja.js");
281 window.onload = function(){
282 var nodeSort = function (a, b){
283 if(typeof a.id === "undefined" && typeof b.id === "undefined"){
286 else if(typeof a.id === "undefined"){
289 else if(typeof b.id === "undefined"){
294 if(a instanceof Box && b instanceof Box){
297 if(a instanceof Box){
300 if(b instanceof Box){
303 if(a instanceof SpriteGroup){
307 if(b instanceof SpriteGroup){
312 if(a instanceof Place){
313 ay += Math.round(a.height * 0.7);
315 if(b instanceof Place){
316 by += Math.round(b.height * 0.7);
319 if(ay < by)return -1;
320 else if(ay > by)return 1;
321 if(a.id < b.id)return -1;
322 else if(a.id > b.id)return 1;
328 var def = new Object();
329 var foodGroup = new Group();
330 var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
331 var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
332 var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
333 var windowFront = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
334 var game = new Game(GAME_WIDTH, GAME_HEIGHT);
338 var tmpName = EResPathReimu.getName();
340 for(var _v in EResPathReimu){
341 if(typeof EResPathReimu[_v] === "function")continue;
342 EResPath[_v + "_" + tmpName] = EResPathReimu[_v];
348 for(var _v in EResPath){
349 _loadArr[i] = EResPath[_v];
352 game.preload(_loadArr);
353 var MapGroup = enchant.Class.mixClasses(Map, Group,true);
354 var backgroundMap = new MapGroup(16, 16);
355 include("./class.js");
356 include("./ctrl.js");
359 ctl.setBackgroundMap(backgroundMap);
360 var Action = enchant.Class.create({
361 initialize: function (yukkuri){
362 this.status = EAction.THINK;
363 this.yukkuri = yukkuri;
364 this.isMoving = false;
365 this.targetNode = null;
367 getStatus: function(){
370 setStatus: function(eaction){
371 this.status = eaction;
374 if(this.yukkuri.isDead()){
375 this.status = EAction.DEAD;
377 // else if(this.yukkuri.isSleep()){
378 // this.status = EAction.SLEEP;
388 if(this.waitCnt >= BASE_FPS * 60 * 24 * 3){
390 this.setStatus(EAction.THINK);
391 console.log("wait cnt end");
394 case EAction.THINK_IN_HOME:
397 this.think_in_home();
399 case EAction.EAT_IN_HOME:
404 if(this.yukkuri.age%2 === 0){
405 this.yukkuri.changeFace();
407 this.yukkuri.searchObjectMang.callEvent(this.yukkuri);
410 case EAction.MOVE_TO_EAT_START:
411 this.move_to_eat_start();
413 case EAction.MOVE_TO_EAT_UNDERWAY:
419 case EAction.SLEEP_START:
422 case EAction.SLEEP_WAIT:
427 case EAction.EAT_START:
430 case EAction.EAT_WAIT:
432 case EAction.UNUN_START:
435 case EAction.UNUN_WAIT:
437 case EAction.MOVE_TO_COMMAND:
438 this.move_to_command();
440 case EAction.UNUN_SMELL_START:
441 this.unun_smell_start();
443 case EAction.COMMUNICATE_START:
444 this.communicate_start();
446 case EAction.COMMUNICATE_WAIT:
448 case EAction.COMMUNICATE_RECV:
450 case EAction.MOVE_TO_PLACE_START_HOMELESS:
451 this.move_to_place_start_homeless();
453 case EAction.DECLARE_PLACE_HOMELESS:
454 this.declare_place_homeless();
456 case EAction.MOVE_TO_HUNT_START:
457 this.move_to_hunt_start();
459 case EAction.HUNT_START:
462 case EAction.MOVE_GOTO_HOME:
463 this.move_goto_home();
465 case EAction.IN_HOME:
470 this.yukkuri.reverse();
472 // thinkHavePlace: function(){
473 // var date = ctl.getDate();
474 // if(this.yukkuri.isPlaceRange()){
477 // if(date === EDate.EVENING
478 // || date === EDate.NIGHT
479 // || date === EDate.MIDNIGHT
481 // this.setStatus(EAction.MOVE_GOTO_HOME);
484 // else if(date === EDate.EVENING){
485 // // if(this.yukkuri.isItemsMax()){
486 // // this.setStatus(EAction.IN_HOME);
489 // // this.setStatus(EAction.MOVE_TO_HUNT_START);
493 // if(this.yukkuri.isVeryKuhuku()){
497 // this.setStatus(EAction.MOVE_GOTO_HOME);
499 // else if(this.yukkuri.isSleep()){
500 // this.setStatus(EAction.SLEEP_START);
502 // else if(this.yukkuri.getUnun() >= 80){
503 // this.setStatus(EAction.UNUN_START);
506 // this.yukkuri.changeFace();
510 think_in_home: function(){
511 var date = ctl.getDate();
512 if((date === EDate.MIDNIGHT)
513 && !this.yukkuri.isSleep()
514 && !this.yukkuri.isVeryKuhuku()
518 "nextStatus":EAction.THINK_IN_HOME,
519 "myYukkuri": this.yukkuri
523 else if(date === EDate.EVENING){
526 else if(this.yukkuri.isVeryKuhuku() && this.yukkuri.getPlace().isFood()){
527 this.setStatus(EAction.EAT_IN_HOME);
530 //marisa is hunting move
531 if(this.yukkuri.beforeHuntingFood !== null){
532 new MoveToHuntEvent({
534 "targetNode": this.yukkuri.beforeHuntingFood,
536 "myYukkuri": this.yukkuri
540 this.setStatus(EAction.WALK);
544 eat_in_home: function(){
546 "targetNode": this.yukkuri.getPlace(),
548 "myYukkuri": this.yukkuri
551 move_to_eat_start : function(){
554 "targetNode": this.targetNode,
556 "myYukkuri": this.yukkuri
562 walk : function(retryCounter){
563 if(retryCounter > 15){
565 this.status = EAction.NONE;
566 console.log("retryCount over");
569 if(this.yukkuri.imgGroup.tl.queue.length === 0){
571 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
573 this.isMoving = false;
574 this.status = EAction.THINK;
578 var xpos = 150 + rand(40) - (retryCounter * 10);
579 var ypos = 150 + rand(40) - (retryCounter * 10);
582 this.yukkuri.vy = -ypos;
584 else if(rand(8) == 1){
585 this.yukkuri.vx = xpos;
586 this.yukkuri.vy = -ypos;
587 this.yukkuri.direction = EDirection.RIGHT;
589 else if(rand(8) == 2){
590 this.yukkuri.vx = xpos;
592 this.yukkuri.direction = EDirection.RIGHT;
594 else if(rand(8) == 3){
595 this.yukkuri.vx = xpos;
596 this.yukkuri.vy = ypos;
597 this.yukkuri.direction = EDirection.RIGHT;
599 else if(rand(8) == 4){
601 this.yukkuri.vy = ypos;
603 else if(rand(8) == 5){
604 this.yukkuri.vx = -xpos;
605 this.yukkuri.vy = ypos;
606 this.yukkuri.direction = EDirection.LEFT;
608 else if(rand(8) == 6){
609 this.yukkuri.vx = -xpos;
611 this.yukkuri.direction = EDirection.LEFT;
613 else if(rand(8) == 7){
614 this.yukkuri.vx = -xpos;
615 this.yukkuri.vy = -ypos;
616 this.yukkuri.direction = EDirection.LEFT;
618 if (this.yukkuri.vx || this.yukkuri.vy) {
619 var map = ctl.backgroundMap;
620 // var x = this.yukkuri.x + (this.yukkuri.moveX ? this.yukkuri.moveX / Math.abs(this.yukkuri.moveX) * 16 : 0) + 16;
621 // var y = this.yukkuri.y + (this.yukkuri.moveY ? this.yukkuri.moveY / Math.abs(this.yukkuri.moveY) * 16 : 0) + 16;
622 var x = this.yukkuri.imgGroup.x + this.yukkuri.vx;
623 var y = this.yukkuri.imgGroup.y + this.yukkuri.vy + this.yukkuri.height / 2;
624 if (0 <= x && x < map.width && 0 <= y && y < map.height && !map.hitTest(x, y)) {
625 // console.log("あたってないよ:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
626 // console.log("X:" + this.yukkuri.moveX);
627 // console.log("Y:" + this.yukkuri.moveY);
628 this.isMoving = true;
629 this.yukkuri.reverse();
630 this.yukkuri.moveBy(this.yukkuri.vx, this.yukkuri.vy, frame);
631 mangMsg.output(this.yukkuri,EMsg.WALK);
633 this.targetNode = null;
635 // console.log("HIT:"+ this.yukkuri.imgGroup.x + ":" + this.yukkuri.imgGroup.y);
636 this.walk(retryCounter+1);
642 sleep_start: function(){
645 "myYukkuri": this.yukkuri
649 mangMsg.output(this.yukkuri, EMsg.DEAD);
650 this.yukkuri.tlPause();
651 this.yukkuri.setBodyImage(EBody.DEAD);
653 eat_start: function(){
656 "targetNode": this.targetNode,
658 "myYukkuri": this.yukkuri
662 unun_start: function(){
665 "myYukkuri": this.yukkuri
668 unun_smell_start: function(){
671 "myYukkuri": this.yukkuri
674 communicate_start:function(){
675 new ComSayHelloSendEvent({
677 "targetNode": this.targetNode,
679 "myYukkuri": this.yukkuri
682 move_to_place_start_homeless:function(){
683 new MoveToPlaceStartHomelessEvent({
684 "targetNode": this.targetNode,
686 "myYukkuri": this.yukkuri
689 declare_place_homeless:function(){
690 new DeclarePlaceHomelessEvent({
691 "targetNode": this.targetNode,
693 "myYukkuri": this.yukkuri
696 move_to_hunt_start:function(){
697 new MoveToHuntEvent({
699 "targetNode": this.targetNode,
701 "myYukkuri": this.yukkuri
704 hunt_start:function(){
707 "targetNode": this.targetNode,
709 "myYukkuri": this.yukkuri
712 move_goto_home:function(){
713 var place = this.yukkuri.getPlace();
714 new MoveGotoHomeEvent({
718 "myYukkuri": this.yukkuri
722 var place = this.yukkuri.getPlace();
727 "myYukkuri": this.yukkuri
730 move_to_command: function(){
731 var obj = this.yukkuri.searchObjectMang.currentCmdObject;
732 new MoveToCommandEvent({
735 "myYukkuri": this.yukkuri
740 this.yukkuri.clearSearchObject();
741 var nodes = ctl.getObjs();
744 for (var key in nodes) {
745 var node = nodes[key];
746 if(this.yukkuri.id === node.id)continue;
750 && !(this.targetNode instanceof Unun)
751 && this.yukkuri.within(node, this.yukkuri.getRange() / 3)) {
753 this.yukkuri.addSearchObject(ESearch.UNUN, node);
756 else if (node instanceof Food && node.amount > 0) {
757 if(this.yukkuri.within(node, this.yukkuri.getRange())){
758 this.yukkuri.addSearchObject(ESearch.FOOD, node);
762 else if(node instanceof Yukkuri){
763 if(this.yukkuri.within(node, this.yukkuri.getRange())){
764 this.yukkuri.addSearchObject(ESearch.YUKKURI, node);
768 else if(node instanceof Place){
769 if(this.yukkuri instanceof Player){
771 if(this.yukkuri.within(node, this.yukkuri.getRange())){
772 this.yukkuri.addSearchObject(ESearch.PLACE, node);
776 this.status = EAction.WALK;
780 * Range範囲内のObjSprを管理する
781 * 注意!:ゆっくりプレイスを持って入るもののみ使用される
785 var SearchObjectMang = enchant.Class.create({
786 initialize: function (){
788 this.currentCmdObject = null;
792 for(var key in ESearch){
793 var esearch = ESearch[key];
794 this.datas[esearch] = [];
797 add :function(esearch, node){
798 this.datas[esearch].push(node);
801 for(var key in ESearch){
802 var esearch = ESearch[key];
803 this.datas[esearch].length = 0;
805 // this.datas.length = 0;
808 get:function (esearch){
809 return this.datas[esearch];
811 getNear:function (esearch, yukkuri){
812 var objects = this.datas[esearch];
813 var nearDistance = null;
815 for(var i=0;i<objects.length;i++){
816 var object = objects[i];
817 var nowDistance = object.getX() + object.getY() - yukkuri.getX() + yukkuri.getY();
818 if(nearDistance === null || nearDistance > nowDistance){
819 nearDistance = nowDistance;
825 callEvent: function(yukkuri){
826 if(yukkuri.cmdQueue.length !== 0){
827 this.currentCmdObject = yukkuri.cmdQueue.shift();
828 yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
832 if(yukkuri.isItemsMax() && yukkuri.isPlace()){
833 yukkuri.action.targetNode = yukkuri.getPlace();
834 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
837 if(yukkuri.isVeryKuhuku()){
839 var foods = this.get(ESearch.FOOD);
840 if(foods.length > 0){
841 var foods = this.get(ESearch.FOOD);
842 food = this.getNear(ESearch.FOOD, yukkuri);
844 yukkuri.action.targetNode = food;
845 yukkuri.action.setStatus(EAction.MOVE_TO_EAT_START);
849 if(yukkuri.getMemory(EMemory.FOOD_IN_PLACE) === 0 && yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
850 yukkuri.action.setStatus(EAction.WALK);
854 if(foods.length === 0 && yukkuri.isPlace()){
856 yukkuri.action.targetNode = yukkuri.getPlace();
857 yukkuri.action.setStatus(EAction.MOVE_GOTO_HOME);
863 if(yukkuri.isSleep()){
864 yukkuri.action.setStatus(EAction.SLEEP_START);
868 else if(yukkuri.getUnun() >= 80){
869 yukkuri.action.setStatus(EAction.UNUN_START);
874 if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
875 food = this.getNear(ESearch.FOOD, yukkuri);
877 yukkuri.action.targetNode = food;
878 yukkuri.action.setStatus(EAction.MOVE_TO_HUNT_START);
882 ununs = this.get(ESearch.UNUN);
883 if(ununs.length !== 0){
884 yukkuri.action.targetNode = yukkuri.getPlace();
885 yukkuri.action.setStatus(EAction.UNUN_SMELL_START);
888 var searchYukkuri = this.getNear(ESearch.YUKKURI, yukkuri);
889 if(searchYukkuri !== null && yukkuri.isCommunication(searchYukkuri)){
890 yukkuri.action.targetNode = searchYukkuri;
891 yukkuri.action.setStatus(EAction.COMMUNICATE_START);
894 if(!yukkuri.isPlace()){
895 var searchYukkuri = this.getNear(ESearch.PLACE, yukkuri);
896 if(searchYukkuri != null && !searchYukkuri.isOwner()){
897 yukkuri.action.targetNode = searchYukkuri;
898 yukkuri.action.setStatus(EAction.MOVE_TO_PLACE_START_HOMELESS);
902 yukkuri.action.setStatus(EAction.WALK);
907 var Event = enchant.Class.create({
908 initialize: function (_data){
911 onactionstart:function(self){
912 return this._onactionstart;
914 _onactionstart:function(e){
915 if(typeof e === "undefined")return;
917 onactiontick:function(self){
919 if(typeof e === "undefined")return;
922 onactionend:function(self){
924 if(typeof e === "undefined")return;
928 var WalkEvent = enchant.Class.create(Event,{
929 initialize: function (_data){
931 this.yukkuri = _data.myYukkuri;
932 this.action = _data.action;
934 mangMsg.output(this.yukkuri, EMsg.SLEEP);
935 this.action.setStatus(EAction.SLEEP_WAIT);
936 this.yukkuri.setFaceImage(EFace.SLEEP);
937 this.yukkuri.tlPause();
939 this.yukkuri.addEventListener('enterframe', function() {
940 var yukkuri = self.yukkuri;
948 var SleepEvent = enchant.Class.create(Event,{
949 initialize: function (_data){
951 this.yukkuri = _data.myYukkuri;
952 this.action = _data.action;
954 mangMsg.output(this.yukkuri, EMsg.SLEEP);
955 this.action.setStatus(EAction.SLEEP_WAIT);
956 this.yukkuri.setFaceImage(EFace.SLEEP);
957 this.yukkuri.tlPause();
960 this.yukkuri.addEventListener('enterframe', function() {
961 var yukkuri = self.yukkuri;
962 if(yukkuri.age%2 === 0 && yukkuri.age !== 0)yukkuri.param.sleep--;
963 if(yukkuri.param.sleep <= 0){
964 yukkuri.param.sleep = 0;
965 this.removeEventListener("enterframe",arguments.callee);
966 mangMsg.output(self.yukkuri, EMsg.GET_UP);
967 yukkuri.setFaceImage(EFace.NORMAL);
969 // self.action.setStatus(EAction.WAIT);
970 if(self.data.nextStatus !== undefined){
971 self.action.setStatus(self.data.nextStatus);
973 self.action.setStatus(EAction.THINK);
980 var UnunEvent = enchant.Class.create(Event,{
981 initialize: function (_data){
983 this.yukkuri = _data.myYukkuri;
984 this.action = _data.action;
985 this.action.setStatus(EAction.UNUN_WAIT);
986 mangMsg.output(this.yukkuri, EMsg.UNUN);
987 this.yukkuri.setFaceImage(EFace.HAPPY2);
990 this.yukkuri.wait(sec, {
991 "onactionend": this.onactionend(this)
994 onactionend:function(self){
996 if(typeof e === "undefined")return;
998 self.action.setStatus(EAction.WAIT);
999 mangMsg.output(self.yukkuri, EMsg.UNUN_END);
1001 "waitframe": FPS * 1.5,
1002 "action": self.action,
1003 "myYukkuri": self.yukkuri
1008 var WaitEvent = enchant.Class.create(Event,{
1009 initialize: function (_data){
1011 this.yukkuri = _data.myYukkuri;
1012 this.action = _data.action;
1013 this.waitframe = _data.waitframe;
1014 this.yukkuri.wait(this.waitframe, {
1015 "onactionstart": this.onactionstart(this),
1016 "onactiontick": this.onactiontick(this),
1017 "onactionend": this.onactionend(this)
1020 onactionend:function(self){
1022 if(typeof e === "undefined")return;
1023 self.action.setStatus(EAction.THINK);
1027 var UnunSmellEvent = enchant.Class.create(Event,{
1028 initialize: function (_data){
1030 this.yukkuri = _data.myYukkuri;
1031 this.action = _data.action;
1032 this.action.setStatus(EAction.UNUN_SMELL_WAIT);
1033 mangMsg.output(this.yukkuri, EMsg.UNUN_SMELL);
1034 this.yukkuri.setFaceImage(EFace.CRY1);
1036 this.yukkuri.setYukkuri(this.yukkuri.getYukkuri() - 3);
1037 this.yukkuri.wait(sec, {
1038 "onactionend": this.onactionend(this)
1041 onactionend:function(self){
1043 if(typeof e === "undefined")return;
1044 self.action.setStatus(EAction.WALK);
1049 var EatEvent = enchant.Class.create(Event,{
1050 initialize: function (_data){
1052 this.yukkuri = _data.myYukkuri;
1053 this.food = _data.targetNode;
1054 this.action = _data.action;
1055 this.action.setStatus(EAction.EAT_WAIT);
1058 var sec = BASE_FPS * 3;
1059 if(this.yukkuri.eat(this.food)){
1060 mangMsg.output(this.yukkuri, EMsg.EAT);
1061 this.yukkuri.setFaceImage(EFace.EAT2);
1064 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1065 this.yukkuri.setFaceImage(EFace.CRY2);
1067 this.yukkuri.wait(sec, {
1068 "onactionend": this.onactionend(this)
1071 onactionend:function(self){
1073 if(typeof e === "undefined")return;
1074 if(self.food == null || self.food.getAmount() <= 0 || self.yukkuri.isManpuku()){
1075 self.action.setStatus(EAction.THINK);
1076 self.yukkuri.setFaceImage(EFace.NORMAL);
1078 self.action.setStatus(EAction.EAT_START);
1085 * -When yukkuri find Food.
1088 * targetNode: enchant.Node
1092 var MoveToEatEvent = enchant.Class.create(Event,{
1093 initialize: function (_data){
1095 this.yukkuri = this.data.myYukkuri;
1096 this.action = this.data.action;
1098 var yukkuri = this.yukkuri;
1099 var node = this.data.targetNode;
1101 if(this.data.type == "food"){
1102 this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
1103 yukkuri.vx = node.x - yukkuri.getX() + node.width / 2;
1104 yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
1105 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1106 var frame = distance + distance/5 + 1;
1107 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1108 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1111 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1112 "onactionstart": this.onactionstart(this),
1113 "onactiontick": this.onactiontick(this),
1114 "onactionend": this.onactionend(this)
1118 onactionstart:function(self){
1120 if(typeof e === "undefined")return;
1121 mangMsg.output(self.yukkuri, EMsg.TARGETING_EAT);
1124 onactiontick:function(self){
1126 if(typeof e === "undefined")return;
1129 onactionend:function(self){
1131 if(typeof e === "undefined")return;
1132 self.action.setStatus(EAction.EAT_START);
1136 var MoveToHuntEvent = enchant.Class.create(Event,{
1137 initialize: function (_data){
1139 this.yukkuri = this.data.myYukkuri;
1140 this.action = this.data.action;
1142 var yukkuri = this.yukkuri;
1143 var node = this.data.targetNode;
1146 var nodeWidth = node.width;
1147 var nodeHeight = node.height;
1151 if(this.data.type == "food"){
1152 this.action.setStatus(EAction.WAIT);
1153 yukkuri.vx = nodeX - yukkuri.getX() + nodeWidth / 2;
1154 yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2;
1155 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1156 var frame = distance + distance/5 + 1;
1157 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1158 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1160 mangMsg.output(yukkuri, EMsg.TARGETING_EAT);
1162 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1163 "onactionend": this.onactionend(this)
1167 onactionend:function(self){
1169 if(typeof e === "undefined")return;
1170 self.action.setStatus(EAction.HUNT_START);
1174 var HuntStartEvent = enchant.Class.create(Event,{
1175 initialize: function (_data){
1176 Event.call(this, _data);
1179 this.yukkuri = _data.myYukkuri;
1180 this.food = _data.targetNode;
1181 this.action = _data.action;
1182 this.action.setStatus(EAction.WAIT);
1183 this.huntingStatus = "hunting";
1185 this.yukkuri.beforeHuntingFood = this.food;
1186 var sec = BASE_FPS * 8;
1187 if(this.yukkuri.hunt(this.food)){
1188 this.huntingStatus = "hunting";
1189 mangMsg.output(this.yukkuri, EMsg.HUNTING_MESSAGE);
1190 this.yukkuri.setFaceImage(EFace.HAPPY1);
1192 if(this.yukkuri.isItemsMax()){
1194 this.huntingStatus = "return";
1195 // mangMsg.output(this.yukkuri, EMsg.REHUNT);
1196 this.yukkuri.setFaceImage(EFace.NORMAL);
1199 this.huntingStatus = "cry";
1200 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1201 this.yukkuri.setFaceImage(EFace.CRY2);
1205 this.yukkuri.wait(sec, {
1206 "onactiontick": this.onactiontick(this),
1207 "onactionend": this.onactionend(this)
1210 onactiontick:function(self){
1212 if(typeof e === "undefined")return;
1214 if(self.huntingStatus == "hunting" && self.tick > BASE_FPS * 1){
1215 if(this.age%(BASE_FPS * 5) == 0){
1216 // mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1217 mangMsg.output(self.yukkuri, EMsg.HUNTING_MESSAGE);
1222 onactionend:function(self){
1224 if(typeof e === "undefined")return;
1225 if(self.huntingStatus == "hunting"){
1226 if(self.yukkuri.isItemsMax()){
1227 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1228 // mangMsg.output(self.yukkuri, EMsg.MOVE_GOTO_HOME);
1230 self.action.setStatus(EAction.HUNT_START);
1233 else if(self.huntingStatus == "return"){
1234 self.action.setStatus(EAction.MOVE_GOTO_HOME);
1236 else if(self.huntingStatus === "cry"){
1237 // self.action.setStatus(EAction.THINK);
1238 self.action.setStatus(EAction.WALK);
1245 this.yukkuri = null;
1250 var MoveGotoHomeEvent = enchant.Class.create(Event,{
1251 initialize: function (_data){
1253 this.yukkuri = this.data.myYukkuri;
1254 this.action = this.data.action;
1256 var yukkuri = this.yukkuri;
1257 var place = this.data.targetNode;
1259 if(this.data.type == "hunt_end"){
1260 this.action.setStatus(EAction.WAIT);
1261 yukkuri.vx = place.x - yukkuri.getX() + place.width / 2;
1262 yukkuri.vy = place.y - yukkuri.getY() - yukkuri.getHeight() / 2 + place.height;
1263 // console.log("place.x:" + place.x);
1264 // console.log("place.y:" + place.y);
1265 // console.log("yukkuri.getX():" + yukkuri.getX());
1266 // console.log("yukkuri.getY():" + yukkuri.getY());
1267 // console.log("yukkuri.vx:" + yukkuri.vx);
1268 // console.log("yukkuri.vy:" + yukkuri.vy);
1269 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1270 var frame = distance + distance/2 + 1 ;
1271 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1272 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1274 mangMsg.output(this.yukkuri, EMsg.MOVE_GOTO_HOME)
1276 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1277 "onactiontick": this.onactiontick(this),
1278 "onactionend": this.onactionend(this)
1282 onactiontick:function(self){
1284 if(typeof e === "undefined")return;
1285 if(this.age%(BASE_FPS * 5) == 0){
1286 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1290 onactionend:function(self){
1292 if(typeof e === "undefined")return;
1293 self.action.setStatus(EAction.IN_HOME);
1299 this.yukkuri = null;
1303 var InHomeEvent = enchant.Class.create(Event,{
1304 initialize: function (_data){
1306 this.yukkuri = this.data.myYukkuri;
1307 this.action = this.data.action;
1309 var yukkuri = this.yukkuri;
1310 var place = this.data.targetNode;
1312 if(yukkuri.isVeryKuhuku()){
1314 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1315 this.action.setStatus(EAction.EAT_IN_HOME);
1318 yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 0);
1320 if(yukkuri.getExSkill(EExSkill.NO_FOOD_IN_PLACE) >= 1){
1321 mangMsg.output(yukkuri, EMsg.LEARN_NO_FOOD_IN_PLACE);
1322 this.action.setStatus(EAction.THINK);
1325 mangMsg.output(yukkuri, EMsg.EAT_FAILED);
1326 yukkuri.addExValue(EExSkill.NO_FOOD_IN_PLACE, 50);
1331 this.action.setStatus(EAction.WAIT);
1332 var items = this.yukkuri.getItems();
1333 if(items.length > 0){
1334 place.setItems(items);
1338 var sec = BASE_FPS * 10;
1339 if(place.isFood())yukkuri.setMemory(EMemory.FOOD_IN_PLACE, 1);
1340 this.yukkuri.wait(sec, {
1341 "onactiontick": this.onactiontick(this),
1342 "onactionend": this.onactionend(this)
1345 onactiontick:function(self){
1347 if(typeof e === "undefined")return;
1348 if(this.age%(BASE_FPS * 5) == 0){
1349 mangMsg.output(self.yukkuri, EMsg.YYUYYU)
1353 onactionend:function(self){
1355 if(typeof e === "undefined")return;
1356 self.action.setStatus(EAction.THINK_IN_HOME);
1360 var EatInHomeEvent = enchant.Class.create(Event,{
1361 initialize: function (_data){
1363 this.yukkuri = _data.myYukkuri;
1364 this.place = _data.targetNode;
1365 this.action = _data.action;
1366 this.action.setStatus(EAction.EAT_WAIT);
1368 var sec = BASE_FPS * 3;
1369 var foodHash = this.place.getFoodHash();
1370 if(foodHash !== false && this.yukkuri.eat(foodHash)){
1371 mangMsg.output(this.yukkuri, EMsg.EAT);
1372 this.yukkuri.setFaceImage(EFace.EAT2);
1375 mangMsg.output(this.yukkuri, EMsg.EAT_FAILED);
1376 this.yukkuri.setFaceImage(EFace.CRY2);
1379 this.yukkuri.wait(sec, {
1380 "onactionend": this.onactionend(this)
1383 onactionend:function(self){
1385 if(typeof e === "undefined")return;
1386 if(self.place.isFood() && !self.yukkuri.isManpuku()){
1387 self.action.setStatus(EAction.EAT_IN_HOME);
1389 // new EatInHomeEvent({
1390 // "targetNode": self.place,
1391 // "action": self.action,
1392 // "myYukkuri": self.yukkuri
1395 self.action.setStatus(EAction.THINK_IN_HOME);
1396 self.yukkuri.setFaceImage(EFace.NORMAL);
1403 var MoveToCommandEvent = enchant.Class.create(Event,{
1404 initialize: function (_data){
1406 this.yukkuri = this.data.myYukkuri;
1407 this.action = this.data.action;
1408 // this.vx = this.data.cmdObject.vx;
1409 // this.vy = this.data.cmdObject.vy;
1410 // var vx = (-backgroundMap.x + e.x) - this.ctl.player.getX() ;
1413 var yukkuri = this.yukkuri;
1414 this.action.status = EAction.WAIT;
1415 yukkuri.vx = this.data.cmdObject.touchX - this.yukkuri.getX();
1416 yukkuri.vy = this.data.cmdObject.touchY - this.yukkuri.getY();
1417 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1418 var frame = distance + distance/2 + 1;
1419 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1421 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1423 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1424 "onactiontick": this.onactiontick(this),
1425 "onactionend": this.onactionend(this)
1428 onactiontick:function(self){
1430 if(typeof e === "undefined")return;
1433 onactionend:function(self){
1435 if(typeof e === "undefined")return;
1436 self.action.setStatus(EAction.THINK);
1441 * Say hello contact to send communication .
1443 var ComSayHelloSendEvent = enchant.Class.create(Event,{
1444 initialize: function (_data){
1446 this.yukkuri = _data.myYukkuri;
1447 this.targetYukkuri = _data.targetNode;
1448 this.action = _data.action;
1449 this.action.setStatus(EAction.COMMUNICATE_WAIT);
1450 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1453 this.targetYukkuri.action.setStatus(EAction.COMMUNICATE_RECV);
1454 this.targetYukkuri.tlPause();
1455 this.yukkuri.tlPause();
1456 this.yukkuri.syncDirection(this.targetYukkuri);
1458 this.yukkuri.addAddress(this.targetYukkuri);
1459 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1461 var sec = BASE_FPS * 2;
1462 this.yukkuri.wait(sec, {
1463 "onactiontick": this.onactiontick(this),
1464 "onactionend": this.onactionend(this)
1467 onactiontick:function(self){
1469 if(typeof e === "undefined")return;
1472 onactionend:function(self){
1474 if(typeof e === "undefined")return;
1475 new ComSayHelloRecvEvent({
1477 "targetNode": self.yukkuri,
1478 "action": self.targetYukkuri.action,
1479 "myYukkuri": self.targetYukkuri
1484 var ComSayHelloRecvEvent = enchant.Class.create(Event,{
1485 initialize: function (_data){
1487 this.yukkuri = _data.myYukkuri;
1488 this.targetYukkuri = _data.targetNode;
1489 this.action = _data.action;
1490 mangMsg.output(this.yukkuri, EMsg.SAY_HELLO, this.targetYukkuri);
1491 this.yukkuri.addAddress(this.targetYukkuri);
1492 this.yukkuri.getAddress(this.targetYukkuri).isGreeting = true;
1494 var sec = BASE_FPS * 2;
1495 this.yukkuri.wait(sec, {
1496 "onactiontick": this.onactiontick(this),
1497 "onactionend": this.onactionend(this)
1500 onactiontick:function(self){
1502 if(typeof e === "undefined")return;
1505 onactionend:function(self){
1507 if(typeof e === "undefined")return;
1508 self.action.setStatus(EAction.THINK);
1510 self.yukkuri.action.setStatus(EAction.THINK);
1511 self.yukkuri.animation();
1512 self.targetYukkuri.action.setStatus(EAction.THINK);
1513 self.targetYukkuri.animation();
1517 var MoveToPlaceStartHomelessEvent = enchant.Class.create(Event,{
1518 initialize: function (_data){
1520 this.yukkuri = this.data.myYukkuri;
1521 this.action = this.data.action;
1523 var yukkuri = this.yukkuri;
1524 var node = this.data.targetNode;
1526 this.action.status = EAction.MOVE_TO_PLACE_HOMELESS_UNDERWAY;
1527 yukkuri.vx = node.x + node.width /2 - yukkuri.getX();
1528 yukkuri.vy = node.y + node.height - yukkuri.getY() - yukkuri.getHeight() / 2;
1529 var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
1530 var frame = distance + distance/5 + 1;
1531 frame += plusFrameScale(frame, this.yukkuri.getMyScale());
1533 yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
1536 yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
1537 "onactionend": this.onactionend(this)
1540 onactionend:function(self){
1542 if(typeof e === "undefined")return;
1543 self.action.setStatus(EAction.DECLARE_PLACE_HOMELESS);
1545 self.yukkuri = null;
1550 var DeclarePlaceHomelessEvent = enchant.Class.create(Event,{
1551 initialize: function (_data){
1553 this.yukkuri = _data.myYukkuri;
1554 this.place = _data.targetNode;
1555 this.action = _data.action;
1556 this.action.setStatus(EAction.WAIT);
1559 var sec = BASE_FPS * 3;
1560 this.yukkuri.declarePlace(this.place);
1561 this.place.setOwner(this.yukkuri);
1562 mangMsg.output(this.yukkuri, EMsg.DECLARE_PLACE);
1564 this.yukkuri.setFaceImage(EFace.NORMAL);
1565 this.yukkuri.wait(sec, {
1566 "onactionend": this.onactionend(this)
1569 onactionend:function(self){
1571 if(typeof e === "undefined")return;
1572 self.action.setStatus(EAction.THINK);
1577 var Food = enchant.Class.create(ObjSprite,{
1578 initialize: function (type, x, y){
1579 this.classname = "Food";
1580 //一つにつきgiveの値分、hunguryを減少させられる
1581 if(type == "apple"){
1582 ObjSprite.call(this,16,16);
1583 this.image = game.assets[EResPath.OBJECT];
1587 }else if(type == "grass"){
1588 ObjSprite.call(this,64,64);
1589 this.image = game.assets[EResPath.GRASS];
1596 foodGroup.addChild(this);
1597 this.addEventListener('enterframe', function(){
1598 if(this.amount <= 0){
1603 getAmount: function(){
1606 getGive: function(){
1610 var Place = enchant.Class.create(ObjSprite,{
1611 initialize: function (type, x, y){
1612 ObjSprite.call(this,128,128);
1613 this.image = game.assets[EResPath.PLACE_TREE];
1614 this.x = x - this.width / 2;
1615 this.y = y - this.height / 2;
1616 backgroundMap.addChild(this);
1619 for(var key in EFood){
1620 var efood = EFood[key];
1621 this.foods[efood] = 0;
1623 // this.addEventListener('enterframe', function(){
1624 // if(this.age%10 === 0 && this.age !== 0){
1625 // console.log("x/y " + this.x + "/" + this.y);
1627 // if(game.input.left){
1630 // if(game.input.right){
1633 // if(game.input.up){
1636 // if(game.input.down){
1641 getStatusForDisplay: function(){
1644 if(this.owner == null)ownerId = "なし";
1645 else ownerId = this.owner.id;
1646 ret += "プレイスID " + this.id + "\n";
1647 ret += "オーナーID " + ownerId + "\n";
1648 ret += "食料うめぇ " + this.foods[EFood.GREAT] + "\n";
1649 ret += "食料それなりー " + this.foods[EFood.NORMAL] + "\n";
1650 ret += "食料にがにが " + this.foods[EFood.BAD] + "\n";
1653 setItems:function(items){
1654 var len = items.length;
1655 for(var i=0; i<len; i++){
1656 var item = items[i];
1657 if(item instanceof Food){
1658 this.foods[EFood.NORMAL]++;
1665 for(var key in EFood){
1666 var efood = EFood[key];
1667 ret += this.foods[efood];
1671 getFoodHash:function(){
1672 if(this.foods[EFood.GREAT] !== 0){
1673 this.foods[EFood.GREAT]--;
1674 return {give:20,yukkuri:15,unun:20};
1676 else if(this.foods[EFood.NORMAL] !== 0){
1677 this.foods[EFood.NORMAL]--;
1678 return {give:10,yukkuri:5,unun:10};
1680 else if(this.foods[EFood.BAD] !== 0){
1681 this.foods[EFood.BAD]--;
1682 return {give:10,yukkuri:-2,unun:10};
1686 setOwner: function(yukkuri){
1687 this.owner = yukkuri;
1689 isOwner: function(){
1690 return this.owner !== null;
1693 var Unun = enchant.Class.create(ObjSprite,{
1694 initialize: function (x, y){
1695 this.classname = "Unun";
1696 ObjSprite.call(this,32,32);
1697 this.image = game.assets[EResPath.YUKKURI_UNUN];
1700 backgroundMap.addChild(this);
1701 this.lifetime = 30 * 24 * 3;
1702 this.addEventListener('enterframe', this.runEnterframe(this));
1703 // game.rootScene.addEventListener('enterframe', this.runEnterframe(this));
1706 runEnterframe:function(self){
1708 if(typeof e === "undefined")return;
1709 if(this.age%BASE_FPS === 0 && this.age !== 0){
1711 if(self.lifetime <= 0){
1712 this.parentNode.removeChild(this);
1713 ctl.backgroundMap.removeChild(this);
1714 ctl.removeObj(this);
1721 // runEnterframe: function(){
1722 // console.log("enterframe:" + this.id);
1725 var Okazari = enchant.Class.create(enchant.Sprite,{
1726 initialize: function(yukkuri){
1727 this.classname = "Okazari";
1728 if(yukkuri.myCode === "REIMU"){
1729 enchant.Sprite.call(this, 80, 32);
1730 this.image = game.assets[EResPathReimu.OKAZARI];
1731 this.x = -CHARA_WIDTH / 2 - 1;
1734 enchant.Sprite.call(this, 64, 64);
1735 this.image = game.assets[EResPath.MARISA_OKAZARI];
1736 this.x = -CHARA_WIDTH / 2;
1737 this.y = -CHARA_HEIGHT / 2 - yukkuri.getWidth()/6;
1739 this.yukkuri = yukkuri;
1741 getWidth: function(){
1743 // return this.width * this.yukkuri.myScaleX;
1745 getHeight: function(){
1747 // return this.height * this.yukkuri.myScaleY;
1750 var Address = enchant.Class.create({
1751 initialize: function(yukkuri){
1752 this.friendlyLv = 1;
1753 this.yukkuri = yukkuri;
1754 this.isGreeting = false;
1755 this.greetingWaitFrame = 0;
1757 "beginSayHello" : false,
1762 set:function(key, value){
1763 this.comMatrix[key] = value;
1766 return this.comMatrix[key];
1770 var Yukkuri = enchant.Class.create(ObjSprite,{
1771 initialize: function(x, y, grow){
1772 ObjSprite.call(this, 64, 64);
1773 this.searchObjectMang = new SearchObjectMang();
1777 this.myCode = "YUKKURI";
1778 this.myName = "ゆっくり";
1779 this.beforeHuntingFood = null;
1780 if(grow == EGrow.ADULT){
1785 else if(grow == EGrow.SUBADULT){
1786 this.myScaleX = 0.8;
1787 this.myScaleY = 0.8;
1790 else if(grow == EGrow.CHILD){
1791 this.myScaleX = 0.6;
1792 this.myScaleY = 0.6;
1795 else if(grow == EGrow.BABY){
1796 this.myScaleX = 0.3;
1797 this.myScaleY = 0.3;
1801 // ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
1802 this.classname = "Yukkuri";
1803 this.addressBook = {};
1804 this.imgGroup = new SpriteGroup();
1805 this.imgBody = new SpriteGroup();
1806 this.imgGroup.id = guid();
1807 this.imgBody.id = guid();
1808 this.x = -CHARA_WIDTH / 2;
1809 this.y = -CHARA_HEIGHT / 2;
1812 this.image = game.assets[EResPath.YUKKURI_BASE];
1813 this.direction = EDirection.RIGHT;
1814 this.addEventListener('enterframe', this.runEnterframe);
1815 this.bodyStatus ={};
1816 this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
1817 this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
1818 this.walkAnimationStatus = EWalkAnimation.END;
1821 this.actionQueue = [];
1823 this.exValueHash = {};
1824 this.memoryHash = {};
1825 for(var _v in EExSkill){
1826 var key = EExSkill[_v];
1827 this.exLvHash[key] = 0;
1828 this.exValueHash[key] = 0;
1832 runEnterframe:function(){
1835 if(this.isDead())return;
1846 if(this.direction == EDirection.RIGHT){
1847 this.imgBody.scaleX = 1;
1849 else if(this.direction == EDirection.LEFT){
1850 this.imgBody.scaleX = -1;
1853 tweet:function(text){
1854 text = text.replace(/%name%/g, this.myName);
1855 this._tweet.text(text, this.x - this._tweet.width/4, this.y - this._tweet.height);
1857 moveTo:function(x, y, time){
1858 this.imgGroup.tl.moveTo(x, y, time, enchant.Easing.SIN_EASEINOUT);
1860 moveBy:function(x, y, time, eventFunctions){
1864 return self.imgGroup.x + x;
1867 return self.imgGroup.y + y;
1870 easing: enchant.Easing.SIN_EASEINOUT
1872 //-Event register [onactionstart,onactiontick,onactionend]
1873 if(eventFunctions !== undefined){
1874 for(var key in eventFunctions){
1875 params[key] = eventFunctions[key];
1878 return this.imgGroup.tl.tween(params);
1880 wait:function(frame, eventFunctions){
1881 this.moveBy(0,1,frame,eventFunctions);
1886 animation: function(){
1889 frame -= plusFrameScale(frame, this.getMyScale()) / 2;
1891 move -= plusFrameScale(move, this.getMyScale());
1892 if(this.walkAnimationStatus == EWalkAnimation.END){
1894 this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
1895 "onactionstart": function(e){
1896 this.walkAnimationStatus = EWalkAnimation.START;
1899 .moveByEx(0, move, frame, enchant.Easing.SWING,
1901 "onactionend": function(e){
1902 this.walkAnimationStatus = EWalkAnimation.END;
1907 this.imgBody.tl.loop();
1910 getMyScale: function(){
1911 return (this.myScaleX + this.myScaleY) / 2;
1913 getWidth: function(){
1914 return this.width * this.myScaleX;
1916 getHeight: function(){
1917 return this.height * this.myScaleY;
1920 return this.imgGroup.x;
1923 return this.imgGroup.y;
1926 this.imgGroup.x += x;
1928 // this.shadow.x += x;
1929 // this._tweet.x += x;
1932 this.imgGroup.y += y;
1934 // this.shadow.y += y;
1935 // this._tweet.y += y;
1937 // changeFace: function(erespath){
1938 // this.face.image = game.assets[erespath];
1940 loadParamsXML: function(url){
1941 var http = new JKL.ParseXML( url );
1942 return http.parse();
1944 runYukkuri: function(){
1945 if(this.param.hungry > 70){
1946 if(this.age%(50 - this.param.hungry - 70) === 0 && this.age !== 0){
1947 this.param.yukkuri -= 1;
1950 else if(this.param.hungry < 10){
1951 if(this.age%50 === 0 && this.age !== 0) this.param.yukkuri += 1;
1954 if(this.param.yukkuri <= 0)this.param.yukkuri = 0;
1955 else if(this.param.yukkuri >= this.param.maxYukkuri)this.param.yukkuri = this.param.maxYukkuri;
1957 runHungry: function(){
1958 if(this.age%50 === 0 && this.age !== 0)this.param.hungry++;
1959 if(this.param.hungry >= 100)this.param.hungry = 100;
1961 runUnun: function(){
1962 if(this.age%50 === 0 && this.age !== 0)this.param.unun++;
1963 if(this.param.unun >= 100)this.param.unun = 100;
1965 runSleep: function(){
1966 if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
1967 if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
1968 if(this.param.sleep >= 100){
1969 this.param.sleep = 100;
1973 runAddress: function(){
1974 for(var key in this.addressBook){
1975 var address = this.addressBook[key];
1977 if(address.isGreeting){
1978 address.greetingWaitFrame++;
1979 if(address.greetingWaitFrame >= DAY){
1980 address.greetingWaitFrame = 0;
1981 address.isGreeting = false;
1986 changeFace: function(){
1987 if(this.param.yukkuri >= 80){
1988 this.setFaceImage(EFace.HAPPY1);
1990 else if(this.param.yukkuri >= 50){
1991 this.setFaceImage(EFace.NORMAL);
1993 else if(this.param.yukkuri >= 30){
1994 this.setFaceImage(EFace.TIRED);
1996 else if(this.param.yukkuri >= 10){
1997 this.setFaceImage(EFace.CRY1);
1999 else if(this.param.yukkuri >= 1){
2000 this.setFaceImage(EFace.CRY2);
2003 getRange: function(){
2004 return this.param.range;
2006 isSleep: function(){
2007 return this.param.sleep >= 100;
2010 return this.param.yukkuri <= 0;
2012 isManpuku: function(){
2013 return this.param.hungry <= 20;
2015 isKuhuku: function(){
2016 return this.param.hungry >= 40;
2018 isVeryKuhuku: function(){
2019 return this.param.hungry >= 80;
2021 getYukkuri: function(){
2022 return this.param.yukkuri;
2024 setYukkuri: function(yukkuri){
2025 this.param.yukkuri = yukkuri;
2026 if(this.param.yukkuri < 0)this.param.yukkuri = 0;
2028 getHungry: function(){
2029 return this.param.hungry;
2031 setHungry: function(hungry){
2032 this.param.hungry = hungry;
2033 if(this.param.hungry < 0)this.param.hungry = 0;
2035 getUnun: function(){
2036 return this.param.unun;
2038 setUnun: function(unun){
2039 this.param.unun = unun;
2040 if(this.param.unun < 0)this.param.unun = 0;
2044 if(food instanceof Food){
2046 if(food.amount > 0){
2048 this.setHungry(this.param.hungry - food.getGive());
2049 this.setUnun(this.getUnun() + food.getGive() / 4);
2050 this.setYukkuri(this.getYukkuri() + 5);
2053 this.setYukkuri(this.getYukkuri() - 5);
2059 this.setHungry(this.param.hungry - food.give);
2060 this.setUnun(this.getUnun() + food.unun);
2061 this.setYukkuri(this.getYukkuri() + food.yukkuri);
2068 hunt:function(food){
2069 if(food.amount > 0){
2070 if(!this.isItemsMax()){
2072 this.items.push(food);
2073 this.setYukkuri(this.getYukkuri() + 1);
2079 declarePlace: function(place){
2082 getPlace:function(){
2085 isPlace: function(){
2086 return this.place !== null;
2090 if(this.direction == EDirection.RIGHT){
2091 new Unun(this.getX(), this.getY() + this.getHeight()/5 );
2093 new Unun(this.getX() - this.getWidth()/5, this.getY() + this.getHeight()/5 );
2097 setBodyImage: function(ebody){
2098 var path = this.bodyStatus[ebody];
2099 this.image = game.assets[path];
2102 // this.imgBody.tl.pause();
2103 // this.imgGroup.tl.pause();
2104 this.imgBody.tl.clear();
2105 this.imgGroup.tl.clear();
2106 this.imgBody.tl.unloop();
2107 this.imgGroup.tl.unloop();
2111 tlResume: function(){
2112 // this.imgBody.tl.resume();
2113 // this.imgGroup.tl.resume();
2116 syncDirection:function(senderYukkuri){
2117 if(this.getX() > senderYukkuri.getX()){
2118 this.direction = EDirection.LEFT;
2119 senderYukkuri.direction = EDirection.RIGHT;
2121 this.direction = EDirection.RIGHT;
2122 senderYukkuri.direction = EDirection.LEFT;
2125 isCommunication: function(yukkuri){
2126 if(this.addressBook[yukkuri.id] === undefined) return true;
2127 if(this.addressBook[yukkuri.id].isGreeting) return false;
2130 addAddress: function(yukkuri){
2131 this.addressBook[yukkuri.id] = new Address(yukkuri);
2133 getAddress: function(yukkuri){
2134 if(this.addressBook[yukkuri.id] === undefined)return null;
2135 return this.addressBook[yukkuri.id];
2137 getStatusForDisplay: function (){
2139 var placeId = (this.place==null)?"無し" : this.place.id;
2140 ret += "ID " + this.id + "\n";
2141 ret += "プレイス " + placeId + "\n";
2142 ret += "ゆっくり " + this.getYukkuri() + "\n";
2143 ret += "空腹 " + this.getHungry() + "\n";
2144 ret += "うんうん " + this.getUnun() + "\n";
2145 ret += "もちもの " + this.items.length + "\n";
2146 ret += "debug " + this.action.status + "\n";
2149 isItemsMax:function(){
2150 return this.items.length >= this.param.items_max;
2152 getItems:function(){
2155 addSearchObject:function(esearch, node){
2156 this.searchObjectMang.add(esearch, node)
2158 clearSearchObject:function(){
2159 this.searchObjectMang.clear()
2161 setFaceImage: function(eface){
2162 var path = this.faceStatus[eface];
2163 this.face.image = game.assets[path];
2165 myScale: function(_scaleX, _scaleY){
2166 this.face.scale(_scaleX,_scaleY);
2167 if(this.myCode === "REIMU"){
2168 this.okazari.x = -this.okazari.width / 2;
2169 this.okazari.y = -CHARA_HEIGHT / 2 + (this.okazari.height * (1 - _scaleY)) / 2;
2171 this.okazari.x = -CHARA_WIDTH /2;
2172 this.okazari.y = -CHARA_HEIGHT / 2 - (CHARA_HEIGHT * _scaleY)/6;
2174 if(this.sub1 != null){
2175 this.sub1.scale(_scaleX,_scaleY);
2178 this.okazari.scale(_scaleX,_scaleY);
2179 this.hear.scale(_scaleX,_scaleY);
2180 this.scale(_scaleX,_scaleY);
2181 this.shadow.scale(_scaleX, _scaleY);
2183 send: function(targetYukkuri, object, callback){
2184 targetYukkuri.recv(object, callback);
2186 recv: function(object, callback){
2187 this.actionQueue.push({
2189 actionStatus : EAction.COMMUNICATE_RECV,
2193 addExValue: function(eexskill, plus){
2194 this.exValueHash[eexskill] += plus;
2195 if(this.exValueHash[eexskill] >= 100){
2196 this.exLvHash[eexskill] = 1;
2199 getExValue: function(eexskill){
2200 return this.exValueHash[eexskill];
2202 getExSkill: function(eexskill){
2203 return this.exLvHash[eexskill];
2206 setMemory: function(ememory, value){
2207 this.memoryHash[ememory] = value;
2209 getMemory: function(ememory){
2210 return this.memoryHash[ememory];
2212 destruct: function(){
2216 var Marisa = enchant.Class.create(Yukkuri,{
2217 initialize: function(x, y, grow){
2218 Yukkuri.call(this,x,y, grow);
2219 this.classname = "Marisa";
2220 this.myCode = "MARISA";
2221 this.myName = "まりさ";
2223 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2224 // var json = net.load("./data/marisa/params.json");
2225 // this.param = json.root.param;
2226 this.param = new MarisaParam();
2227 if(this.grow == EGrow.BABY){
2228 this.myName = "まりちゃ";
2229 this.param.range /= 4;
2231 else if(this.grow == EGrow.CHILD){
2232 this.param.range /= 3;
2234 else if(this.grow == EGrow.SUBADULT){
2235 this.param.range *= 0.8;
2238 this.shadow = new enchant.Sprite(64, 64);
2239 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2240 this.shadow.x = 0 + this.x;
2241 this.shadow.y = this.getWidth() / 16 + this.x;
2243 this._style.zIndex = 5;
2245 this.face = new enchant.Sprite(64, 64);
2246 this.face.image = game.assets[EResPath.MARISA_FACE_NORMAL];
2247 this.face.x = -CHARA_WIDTH / 2;
2248 this.face.y = -CHARA_HEIGHT / 2;
2250 this.faceStatus ={};
2251 this.faceStatus[EFace.NORMAL] = EResPath.MARISA_FACE_NORMAL;
2252 this.faceStatus[EFace.CRY1] = EResPath.MARISA_FACE_CRY1;
2253 this.faceStatus[EFace.CRY2] = EResPath.MARISA_FACE_CRY2;
2254 this.faceStatus[EFace.ANGRY] = EResPath.MARISA_FACE_ANGRY;
2255 this.faceStatus[EFace.HAPPY1] = EResPath.MARISA_FACE_HAPPY1;
2256 this.faceStatus[EFace.HAPPY2] = EResPath.MARISA_FACE_HAPPY2;
2257 this.faceStatus[EFace.EAT1] = EResPath.MARISA_FACE_EAT1;
2258 this.faceStatus[EFace.EAT2] = EResPath.MARISA_FACE_EAT2;
2259 this.faceStatus[EFace.TIRED] = EResPath.MARISA_FACE_TIRED;
2260 this.faceStatus[EFace.SLEEP] = EResPath.MARISA_FACE_SLEEP;
2263 this.hear = new enchant.Sprite(64, 64);
2264 this.hear.image = game.assets[EResPath.MARISA_HEAR];
2265 this.hear.x = -CHARA_WIDTH / 2;
2266 this.hear.y = -CHARA_HEIGHT / 2;
2268 this.okazari = new Okazari(this);
2272 this.imgGroup.addChild(this.shadow);
2273 this.imgBody.addChild(this);
2274 this.imgBody.addChild(this.face);
2275 this.imgBody.addChild(this.hear);
2276 this.imgBody.addChild(this.okazari);
2277 this.myScale(this.myScaleX, this.myScaleY)
2278 if(this instanceof Player){
2279 // this.myScaleX = 0.5;
2280 // this.myScaleY = 0.5;
2282 this.budge = new enchant.Sprite(16, 16);
2283 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2284 this.imgBody.addChild(this.budge);
2285 this.budge.x -= this.getWidth()/2;
2286 this.budge.y -= this.getHeight()/2;
2287 this.budge.scale(this.myScaleX, this.myScaleX);
2289 this.imgGroup.width = this.getWidth();
2290 this.imgGroup.height = this.getHeight();
2291 this.imgGroup.addChild(this.imgBody);
2292 backgroundMap.addChild(this.imgGroup);
2293 this._tweet = new TTweet(148, 64);
2295 this.imgGroup.addChild(this._tweet);
2296 this.imgGroup.x = x;
2297 this.imgGroup.y = y;
2300 this.action = new Action(this);
2304 var Player = enchant.Class.create(Marisa,{
2305 initialize: function(x, y){
2306 // this.runEnterframe = function(){
2308 Marisa.call(this, x, y, EGrow.ADULT);
2309 this.classname = "Player";
2310 ctl.setPlayer(this);
2311 // this.removeEventListener('enterframe',this.runEnterframe);
2312 this.addEventListener('enterframe', function(){
2315 if(this.age%10 === 0 && this.age !== 0){
2316 // console.log("palyer:" + this.age);
2319 ///////////////////////////////////////////////
2320 //Action pattern debug
2321 if(game.input.left){
2322 // this.changeFace(EResPath.MARISA_FACE_TIRED);
2324 this.direction = EDirection.LEFT;
2326 if(game.input.right){
2328 this.direction = EDirection.RIGHT;
2333 if(game.input.down){
2337 // if(this.age%20 == 0)console.log("player:" + (this.getY() + this.getHeight()/2));
2338 ///////////////////////////////////////////////
2340 // if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
2341 // console.log("hit:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.height/2) );
2343 // console.log("not:" + this.imgGroup.x + ":" + (this.imgGroup.y + this.image.height/2));
2345 //- Display the circle of search range.
2346 // fieldBg.image.clear();
2347 // fieldBg.image.context.beginPath();
2348 // fieldBg.image.context.fillStyle = '#ff0000';
2349 // fieldBg.image.context.arc(this.imgGroup.x + this.width/2, this.imgGroup.y + this.height/2, this.range, Math.PI * 2, false);
2350 // fieldBg.image.context.fill();
2354 var Reimu = enchant.Class.create(Yukkuri,{
2355 initialize: function(x, y, grow){
2356 Yukkuri.call(this,x,y, grow);
2357 this.classname = "Reimu";
2358 this.myCode = "REIMU";
2359 this.myName = "れいむ";
2361 // var xml = this.loadParamsXML("./data/marisa/params.xml");
2362 // var json = net.load("./data/reimu/params.json");
2363 // this.param = json.root.param;
2364 this.param = new ReimuParam();
2365 if(this.grow == EGrow.BABY){
2366 this.myName = "れいみゅ";
2367 this.param.range /= 4;
2369 else if(this.grow == EGrow.CHILD){
2370 this.param.range /= 3;
2372 else if(this.grow == EGrow.SUBADULT){
2373 this.param.range *= 0.8;
2375 this.shadow = new enchant.Sprite(64, 64);
2376 this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
2377 this.shadow.x = 0 + this.x;
2378 this.shadow.y = this.getWidth() / 16 + this.x;
2379 this.shadow.image._element.style.zIndex = 2;
2381 this._style.zIndex = 5;
2383 this.face = new enchant.Sprite(64, 64);
2384 this.face.image = game.assets[EResPathReimu.FACE_NORMAL];
2385 this.face.x = -CHARA_WIDTH / 2;
2386 this.face.y = -CHARA_HEIGHT / 2;
2387 this.face._style.zIndex = 0;
2389 this.faceStatus ={};
2390 this.faceStatus[EFace.NORMAL] = EResPathReimu.FACE_NORMAL;
2391 this.faceStatus[EFace.CRY1] = EResPathReimu.FACE_CRY1;
2392 this.faceStatus[EFace.CRY2] = EResPathReimu.FACE_CRY2;
2393 this.faceStatus[EFace.ANGRY] = EResPathReimu.FACE_ANGRY;
2394 this.faceStatus[EFace.HAPPY1] = EResPathReimu.FACE_HAPPY1;
2395 this.faceStatus[EFace.HAPPY2] = EResPathReimu.FACE_HAPPY2;
2396 this.faceStatus[EFace.EAT1] = EResPathReimu.FACE_EAT1;
2397 this.faceStatus[EFace.EAT2] = EResPathReimu.FACE_EAT2;
2398 this.faceStatus[EFace.TIRED] = EResPathReimu.FACE_TIRED;
2399 this.faceStatus[EFace.SLEEP] = EResPathReimu.FACE_SLEEP;
2402 this.hear = new enchant.Sprite(64, 64);
2403 this.hear.image = game.assets[EResPathReimu.HEAR];
2404 this.hear.x = -CHARA_WIDTH / 2;
2405 this.hear.y = -CHARA_HEIGHT / 2;
2407 this.sub1 = new enchant.Sprite(64, 64);
2408 this.sub1.image = game.assets[EResPathReimu.SUB1];
2409 this.sub1.x = -CHARA_WIDTH / 2;
2410 this.sub1.y = -CHARA_HEIGHT / 2;
2412 this.okazari = new Okazari(this);
2414 // this.imgGroup._style.zIndex = 1;
2417 this.imgGroup.addChild(this.shadow);
2418 this.imgBody.addChild(this.okazari);
2419 this.imgBody.addChild(this);
2420 this.imgBody.addChild(this.face);
2421 this.imgBody.addChild(this.hear);
2422 this.imgBody.addChild(this.sub1);
2423 this.myScale(this.myScaleX, this.myScaleY)
2424 if(this instanceof Player){
2425 // this.myScaleX = 0.5;
2426 // this.myScaleY = 0.5;
2428 this.budge = new enchant.Sprite(16, 16);
2429 this.budge.image = game.assets[EResPath.PLAYER_BADGE];
2430 this.imgBody.addChild(this.budge);
2431 this.budge.x -= this.getWidth()/2;
2432 this.budge.y -= this.getHeight()/2;
2433 this.budge.scale(this.myScaleX, this.myScaleX);
2435 this.imgGroup.width = this.getWidth();
2436 this.imgGroup.height = this.getHeight();
2437 this.imgGroup.addChild(this.imgBody);
2438 backgroundMap.addChild(this.imgGroup);
2439 this._tweet = new TTweet(148, 64);
2441 this.imgGroup.addChild(this._tweet);
2442 this.imgGroup.x = x;
2443 this.imgGroup.y = y;
2446 this.action = new Action(this);
2448 this.exLvHash[EExSkill.KEKKAI] = 1;
2449 this.exValueHash[EExSkill.KEKKAI] = 100;
2453 game.onload = function(){
2457 def.ObjSprite = ObjSprite;
2458 def.Yukkuri = Yukkuri;
2459 def.nodeSort = nodeSort;
2460 mangTouch = new MangTouch(ctl);
2461 mangMsg = new MangMsg(ctl);
2462 ctl.setDefined(def);
2463 backgroundMap.image = game.assets[EResPath.MAP0];
2464 backgroundMap.loadData(_mapData);
2465 backgroundMap.collisionData = _collisionData;
2467 var menuSurface = new enchant.Surface(EMenuPos.WIDTH, EMenuPos.HEIGHT);
2468 var fieldSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2469 var windowSurface = new enchant.Surface(EFieldPos.WIDTH, EFieldPos.HEIGHT);
2470 fieldBg.image = fieldSurface;
2474 windowFront.image = windowSurface;
2477 windowFront.opacity = 0.5;
2479 windowSurface.context.fillStyle = '#000';
2480 windowSurface.context.fillRect(0 + 20, EFieldPos.HEIGHT - 60, EFieldPos.WIDTH - 40, EFieldPos.HEIGHT);
2483 menuSurface.context.fillStyle = '#000';
2484 menuSurface.context.fillRect(0, 0, EMenuPos.WIDTH, EMenuPos.HEIGHT);
2485 menuBg.image = menuSurface;
2486 menuBg.x = EMenuPos.X;
2487 menuBg.y = EMenuPos.Y;
2488 backgroundMap.addChild(fieldBg);
2489 mangIcon = new MangIcon(ctl, menuBg);
2491 game.rootScene.addChild(backgroundMap);
2492 game.rootScene.addChild(windowFront);
2493 game.rootScene.addChild(menuBg);
2495 // var labelGroup = new LabelGroup();
2496 mangLabel = new MangLabel(ctl, menuBg);
2497 // var info = new Label("ゆっくり");
2498 // info.color = "#ffffff";
2499 // info.font = "14px 'Times New Roman'";
2501 // info.y = GAME_HEIGHT / 2;
2502 // labelGroup.addChild(info);
2503 // menuBg.addChild(labelGroup);
2506 // var food = new def.Food("apple", 200, 250);
2507 backgroundMap.addChild(foodGroup);
2508 // backgroundMap.addChild(placeGroup);
2509 var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
2510 new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
2511 new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
2512 new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
2513 new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
2514 new Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
2515 new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
2516 new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);
2517 new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
2518 // new Unun(100, 100);
2519 // new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
2523 game.rootScene.addEventListener('touchstart', function (e) {
2524 game.touched = true;
2525 var mang = mangTouch.get(ctl.getCurrentCommand());
2528 game.rootScene.addEventListener('touchmove', function (e) {
2529 var mang = mangTouch.get(ctl.getCurrentCommand());
2532 game.rootScene.addEventListener('touchend', function (e) {
2533 var mang = mangTouch.get(ctl.getCurrentCommand());
2535 game.touched = false;
2539 game.rootScene.addEventListener('enterframe', function(){
2541 mangLabel.draw(player);
2542 if(this.age%BASE_FPS == 0 ){
2545 ctl.time += TIME_SPEED;
2547 this.addEventListener('enterframe', function(){
2548 //The priority processing of display instead of z-index
2550 backgroundMap.childNodes.sort(nodeSort);