this.id = guid();
this.mainIndex = 0;
},
- addChildAll:function(){
- for(var i=0;i<this.spriteArray.length;i++){
- this.spriteArray[i].baseX = this.spriteArray[i].x;
- this.spriteArray[i].baseY = this.spriteArray[i].y;
- this.spriteArray[i].anim = new Animation(this.spriteArray[i]);
- this.spriteArray[i].id = guid();
- App.backgroundMap.addChild(this.spriteArray[i]);
- }
- },
+ addChild:function(sprite, index, attr){
+ this.add(sprite, index, attr);
+ sprite.baseX = sprite.x;
+ sprite.baseY = sprite.y;
+ sprite.anim = new Animation(sprite);
+ sprite.id = guid();
+ App.backgroundMap.addChild(sprite);
+ },
+ // addChildAll:function(){
+ // for(var i=0;i<this.spriteArray.length;i++){
+ // if(this.spriteArray[i] === undefined)continue;
+ // this.spriteArray[i].baseX = this.spriteArray[i].x;
+ // this.spriteArray[i].baseY = this.spriteArray[i].y;
+ // this.spriteArray[i].anim = new Animation(this.spriteArray[i]);
+ // this.spriteArray[i].id = guid();
+ // App.backgroundMap.addChild(this.spriteArray[i]);
+ // }
+ // },
/**
attr:
mainIndex:true/false
},
addX: function(x){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
spr.x += x;
}
},
addY: function(y){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
spr.y += y;
}
},
setX: function(x){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
spr.x = x + spr.baseX;
}
},
setY: function(y){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
spr.y = y + spr.baseY;
}
},
+ setFixBudgeLeft: function (index){
+ this.spriteArray[index].x = this.spriteArray[this.mainIndex].x + this.spriteArray[this.mainIndex].width / 3 * 2;
+ this.spriteArray[index].scaleX = 1;
+ },
+ setFixBudgeRight: function (index){
+ this.spriteArray[index].x = this.spriteArray[this.mainIndex].x;
+ },
formScaleX: function(x){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
if(spr.type == "tweet")continue;
spr.scaleX = x;
},
formScaleY: function(y){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
if(spr.type == "tweet")continue;
spr.scaleY = y;
tlMoveBy:function(x, y, time, eventFunctions){
var self = this;
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
if(spr.type == "tweet")continue;
- // var addX = x + spr.baseX;
- // var addY = y + spr.baseX;
var addX = x;
var addY = y;
- // console.log(i+":spry:" + spr.y);
var params = {
x: this.paramX(spr.x, addX),
y: this.paramY(spr.y, addY),
},
paramX : function(x, addX){
return x + addX;
- // return function(){
- // return x + addX;
- // }
},
paramY : function(y, addY){
return y + addY;
},
tlMoveTo:function(x, y, time, easing ){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
spr.tl.moveTo(x, y, time, easing);
}
},
animation: function(){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
- if(spr.type == "body"){
+ if(spr.type == "body" || spr.type == "budge"){
spr.anim.animrun();
}
}
},
scale: function(_scaleX,_scaleY){
for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
var spr = this.spriteArray[i];
if(spr.type == "tweet")continue;
spr.scale(_scaleX, _scaleY);
var CHARA_HEIGHT = 64;
var GAME_WIDTH = 800;
var GAME_HEIGHT = 600;
-var FPS = 40;
+var FPS = 20;
var BASE_FPS = 20;
var HUNGRY_MAX = 100;
var TIME_SPEED = 4;
if(b instanceof Box){
return -1;
}
+ var budgeValue = 10 + 28;
+ var shadowValue = -28;
+ //okazariは他のbodyと比べて11低い
+ var okazariValue = 37 + 11;
+ var bodyValue = 37;
+ var tweetValue = 148;
+
if(a.type == "shadow"){
- ay += -28 * a.scaleValue;
+ ay += shadowValue * a.scaleValue;
}
- if(b.type == "shadow"){
- by += -28 * b.scaleValue;
+ else if(a.type == "body" && a.classname == "Okazari"){
+ ay += okazariValue * a.scaleValue - a.anim.cnt;
}
- if(a.classname == "Okazari"){
- ay += 11 * a.scaleValue;
+ else if(a.type == "body"){
+ ay += bodyValue * a.scaleValue - a.anim.cnt;
}
- if(b.classname == "Okazari"){
- by += 11 * b.scaleValue;
+ else if(a.type == "tweet"){
+ ay += tweetValue * a.scaleValue;
}
- if(a.type == "body"){
- ay += 32 * a.scaleValue;
+ else if(a.type == "budge"){
+ ay += budgeValue * a.scaleValue - a.anim.cnt;
}
- else if(a.type == "tweet"){
- ay += 148 * a.scaleValue;
+
+ if(b.type == "shadow"){
+ by += shadowValue * b.scaleValue;
}
- if(b.type == "body"){
- by += 32 * b.scaleValue;
+
+ else if(b.type == "body" && b.classname == "Okazari"){
+ by += okazariValue * b.scaleValue - b.anim.cnt;
+ }
+ else if(b.type == "body"){
+ by += bodyValue * b.scaleValue - b.anim.cnt;
}
else if(b.type == "tweet"){
- by += 148 * b.scaleValue;
+ by += tweetValue * b.scaleValue;
+ }
+ else if(b.type == "budge"){
+ by += budgeValue * b.scaleValue - b.anim.cnt;
}
+
if(a instanceof SpriteGroup){
ay = a.y;
ay += a.height/2;
if(b instanceof Place){
by += Math.round(b.height * 0.7);
}
- if(a.flgMiYukkuri){
- ay += CHARA_HEIGHT;
- }
- if(b.flgMiYukkuri){
- by += CHARA_HEIGHT;
- }
+ // if(a.flgMiYukkuri){
+ // ay += CHARA_HEIGHT;
+ // }
+ // if(b.flgMiYukkuri){
+ // by += CHARA_HEIGHT;
+ // }
- if(ay < by)return -1;
- else if(ay > by)return 1;
+ if(Math.round(ay) < Math.round(by))return -1;
+ else if(Math.round(ay) > Math.round(by))return 1;
if(a.id < b.id)return -1;
else if(a.id > b.id)return 1;
return 0;
//food distance
if(this.data.type == "food"){
this.action.status = EAction.MOVE_TO_EAT_UNDERWAY;
- yukkuri.vx = node.x - yukkuri.getX() + node.width / 2;
- yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
+ yukkuri.vx = node.x - yukkuri.getX() + node.width / 2 + yukkuri.getWidth() / 2;
+ yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2 + yukkuri.getHeight() / 2;
var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
var frame = distance + distance/5 + 1;
frame += plusFrameScale(frame, this.yukkuri.getMyScale());
//food distance
if(this.data.type == "food"){
this.action.setStatus(EAction.WAIT);
- yukkuri.vx = nodeX - yukkuri.getX();
- yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2;
+ yukkuri.vx = nodeX - yukkuri.getX() + yukkuri.getWidth() / 2;
+ yukkuri.vy = nodeY - yukkuri.getY() - yukkuri.getHeight() / 2 + nodeHeight / 2 + yukkuri.getHeight() / 2;
var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
var frame = distance + distance/5 + 1;
frame += plusFrameScale(frame, this.yukkuri.getMyScale());
// this.kukis[0].miYukkuris[0].animY(-_y);
}
// console.log(this.getX() + ":" + this.getY());
- this.act();
+ // this.act();
if(this.isDead())return;
this.runYukkuri();
this.runHungry();
reverse:function(){
if(this.direction == EDirection.RIGHT){
this.formSprite.formScaleX(this.myScaleX);
+ if(this instanceof Player){
+ this.formSprite.setFixBudgeRight(5);
+ }
// this.formSprite.formScaleY(this.myScale);
// this.imgBody.scaleX = 1;
}
else if(this.direction == EDirection.LEFT){
this.formSprite.formScaleX(-this.myScaleX);
+ if(this instanceof Player){
+ this.formSprite.setFixBudgeLeft(5);
+ }
// this.formSprite.formScaleY(this.myScale);
// this.imgBody.scaleX = -1;
}
this.kukis[3] = new Kuki(this, -5, 5);
this._tweet = new TTweet(this, 148, 64);
- this.formSprite.add(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
- this.formSprite.add(this, 1, {
+ this.formSprite.addChild(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
+ this.formSprite.addChild(this, 1, {
mainIndexFlg:true,
type : "body",
scaleValue:this.myScaleY
});
- this.formSprite.add(this.face,2,{type:"body",scaleValue:this.myScaleY});
- this.formSprite.add(this.hear,3,{type:"body",scaleValue:this.myScaleY});
- this.formSprite.add(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
- this.formSprite.add(this._tweet,5,{type:"tweet",scaleValue:this.myScaleY});
- this.formSprite.addChildAll();
- this.formSprite.setX(x);
- this.formSprite.setY(y);
+ // this.formSprite.add(this.face,2,{type:"body",scaleValue:this.myScaleY});
+ // this.formSprite.add(this.hear,3,{type:"body",scaleValue:this.myScaleY});
+ // this.formSprite.add(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
+ // this.formSprite.add(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
+ // this.formSprite.addChildAll();
+ this.formSprite.addChild(this.face,2,{type:"body",scaleValue:this.myScaleY});
+ this.formSprite.addChild(this.hear,3,{type:"body",scaleValue:this.myScaleY});
+ this.formSprite.addChild(this.okazari,4,{type:"body",scaleValue:this.myScaleY});
+ this.formSprite.addChild(this._tweet,6,{type:"tweet",scaleValue:this.myScaleY});
+ // this.formSprite.addChildAll();
+
// App.backgroundMap.addChild(this._tweet);
// this.imgGroup.addChild(this.shadow);
// this.imgBody.addChild(this);
// this.imgBody.addChild(new Kuki(this));
this.myScale(this.myScaleX, this.myScaleY)
if(this instanceof Player){
- // this.myScaleX = 0.5;
- // this.myScaleY = 0.5;
-
this.budge = new enchant.Sprite(16, 16);
this.budge.image = game.assets[EResPath.PLAYER_BADGE];
- // this.imgBody.addChild(this.budge);
- this.budge.x -= this.getWidth()/2;
- this.budge.y -= this.getHeight()/2;
- this.budge.scale(this.myScaleX, this.myScaleX);
+ this.budge.x = -this.getWidth()/2;
+ this.budge.y = -this.getHeight()/2;
+ this.budge.scale(this.myScaleX, this.myScaleY);
+ this.formSprite.addChild(this.budge,5, {type:"budge",scaleValue:this.myScaleY});
+ this.formSprite.setX(x);
+ this.formSprite.setY(y);
}
// this.imgGroup.width = this.getWidth();
// this.imgGroup.height = this.getHeight();
// var food = new def.Food("apple", 200, 250);
backgroundMap.addChild(foodGroup);
// backgroundMap.addChild(placeGroup);
- var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
+ var player = new Player(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.ADULT);
// var player = new Player(0, 0);
// console.log(player.getX());
// player.addKuki();
// player.createKuki();
- new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
- new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
- new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
- new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
+ // new Marisa(PALYER_INIT_X + 50, PALYER_INIT_Y + 200, EGrow.ADULT);
+ // new Marisa(PALYER_INIT_X + 100, PALYER_INIT_Y + 200, EGrow.SUBADULT);
+ // new Marisa(PALYER_INIT_X + 150, PALYER_INIT_Y + 200, EGrow.CHILD);
+ // new Marisa(PALYER_INIT_X + 200, PALYER_INIT_Y + 200, EGrow.BABY);
// // new Reimu(PALYER_INIT_X + 400, PALYER_INIT_Y + 400, EGrow.ADULT);
// new Reimu(PALYER_INIT_X + 350, PALYER_INIT_Y + 400, EGrow.SUBADULT);
// new Reimu(PALYER_INIT_X + 300, PALYER_INIT_Y + 400, EGrow.CHILD);