MAP0 : './data/map0.png',
COMMAND : './data/command.png',
OKAZARI : './data/okazari.png',
+ PLACE_TREE : './data/system/place_tree.png',
+ // PLACE_TREE : './data/system/rapture.png',
};
var EFace = {
NORMAL:0,
WORLD_CURSOR: 0,
WORLD_TARGET: 1,
WORLD_APPLE: 2,
+ WORLD_PLACE: 3,
};
var EMenuPos = {
EAT_FAILED: 9,
GREETING: 10,
};
+var EWalkAnimation = {
+ START: 0,
+ END: 1,
+};
+enchant.Timeline.prototype.moveByEx = function(x, y, time, easing, eventFunctions){
+ var params = {
+ x: function() {
+ return this.x + x;
+ },
+ y: function() {
+ return this.y + y;
+ },
+ time: time,
+ easing: easing
+ };
+ //-Event register [onactionstart,onactiontick,onactionend]
+ if(eventFunctions !== undefined){
+ for(var key in eventFunctions){
+ params[key] = eventFunctions[key];
+ }
+ }
+ return this.tween(params);
+};
+
+
+
include("./lang/ja.js");
window.onload = function(){
//init game
var def = new Object();
var foodGroup = new Group();
+ // var placeGroup = new Group();
var SpriteGroup = enchant.Class.mixClasses(Sprite, Group,true);
var menuBg = new SpriteGroup(EMenuPos.WIDTH, EMenuPos.HEIGHT);
var fieldBg = new enchant.Sprite(EFieldPos.WIDTH, EFieldPos.HEIGHT);
return this.give;
}
});
+ var Place= enchant.Class.create(ObjSprite,{
+ initialize: function (type, x, y){
+ ObjSprite.call(this,128,128);
+ this.image = game.assets[EResPath.PLACE_TREE];
+ this.x = x - this.width / 2;
+ this.y = y - this.height / 2;
+ // placeGroup.addChild(this);
+ backgroundMap.addChild(this);
+
+ // this.addEventListener('enterframe', function(){
+
+
+ // if(this.age%10 === 0 && this.age !== 0){
+ // console.log("x/y " + this.x + "/" + this.y);
+ // }
+ // if(game.input.left){
+ // this.x -= 10;;
+ // }
+ // if(game.input.right){
+ // this.x += 10;;
+ // }
+ // if(game.input.up){
+ // this.y -= 10;;
+ // }
+ // if(game.input.down){
+ // this.y += 10;;
+ // }
+ // });
+
+ }
+ });
var Unun = enchant.Class.create(ObjSprite,{
initialize: function (x, y){
this.classname = "Unun";
this.bodyStatus ={};
this.bodyStatus[EBody.NORMAL] = EResPath.YUKKURI_BASE;
this.bodyStatus[EBody.DEAD] = EResPath.YUKKURI_BODY_DEAD;
+ this.walkAnimationStatus = EWalkAnimation.END;
},
runEnterframe:function(){
this.act();
params[key] = eventFunctions[key];
}
}
- this.imgGroup.tl.tween(params);
-
+ return this.imgGroup.tl.tween(params);
},
wait:function(frame, eventFunctions){
this.moveBy(0,1,frame,eventFunctions);
this.action.act();
},
animation: function(){
- this.imgBody.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
- // this.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
- // this.okazari.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
- // this.face.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
- // this.hear.tl.moveBy(0, -5, 10, enchant.Easing.SWING).moveBy(0, 5, 10, enchant.Easing.SWING).loop();
+ if(this.walkAnimationStatus == EWalkAnimation.END){
+ this.imgBody.tl.moveByEx(0, -5, 10, enchant.Easing.SWING, {
+ "onactionstart": function(e){
+ this.walkAnimationStatus = EWalkAnimation.START;
+ }
+ })
+ .moveByEx(0, 5, 10, enchant.Easing.SWING,
+ {
+ "onactionend": function(e){
+ this.walkAnimationStatus = EWalkAnimation.END;
+ }
+ }).loop();
+
+ }else{
+ this.imgBody.tl.loop();
+ }
+ // this.imgBody.tl.moveByEx(0, -5, 10, enchant.Easing.SWING)
+ // this.imgBody.tl.moveByEx(0, 5, 10, enchant.Easing.SWING);
+ // this.imgBody.tl.loop();
+ // this.moveBy(0, -5, 10).moveBy(0, 5, 10).loop();
+
},
getWidth: function(){
return this.width;
tlPause:function(){
// this.imgBody.tl.pause();
// this.imgGroup.tl.pause();
- this.imgBody.tl.clear();
- this.imgGroup.tl.clear();
+ // this.imgBody.tl.clear();
+ // this.imgGroup.tl.clear();
this.imgBody.tl.unloop();
this.imgGroup.tl.unloop();
},
this.act();
///////////////////////////////////////////////
//Action pattern debug
- if(game.input.left){
- // this.changeFace(EResPath.MARISA_FACE_TIRED);
- this.moveX(-10);
- this.direction = EDirection.LEFT;
- }
- if(game.input.right){
- this.moveX(10);
- this.direction = EDirection.RIGHT;
- }
- if(game.input.up){
- this.moveY(-10);
- this.tweet("ゆっくりしていってね!");
+ // if(game.input.left){
+ // // this.changeFace(EResPath.MARISA_FACE_TIRED);
+ // this.moveX(-10);
+ // this.direction = EDirection.LEFT;
+ // }
+ // if(game.input.right){
+ // this.moveX(10);
+ // this.direction = EDirection.RIGHT;
+ // }
+ // if(game.input.up){
+ // this.moveY(-10);
+ // this.tweet("ゆっくりしていってね!");
- }
- if(game.input.down){
- this.moveY(10);
- }
+ // }
+ // if(game.input.down){
+ // this.moveY(10);
+ // }
///////////////////////////////////////////////
// this.reverse();
// if(ctl.backgroundMap.hitTest(this.imgGroup.x, this.imgGroup.y + this.height / 2)){
});
game.onload = function(){
def.Food = Food;
+ def.Place = Place;
mangTouch = new MangTouch(ctl);
mangMsg = new MangMsg(ctl);
ctl.setDefined(def);
// var food = new def.Food("apple", 200, 250);
backgroundMap.addChild(foodGroup);
+ // backgroundMap.addChild(placeGroup);
var player = new Player(PALYER_INIT_X, PALYER_INIT_Y);
new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y);
var touchX = 0;
else if(typeof b.id === "undefined"){
return 1;
}
- if(a.y < b.y)return -1;
- if(a.y > b.y)return 1;
+ var ay = a.y;
+ var by = b.y;
+ if(a instanceof Place){
+ ay += Math.round(a.height * 0.7);
+ }
+ else if(b instanceof Place){
+ by += Math.round(b.height * 0.7);
+ }
+
+ if(ay < by)return -1;
+ if(ay > by)return 1;
return 0;
}
);