var Animation = enchant.Class.create({
initialize: function (sprite){
this.cnt = 0;
+ this.cntUp = 0;
+ this.cntDown = 0;
+ this.accCnt = 0;
this.maxY = -4;
this.minY = 0;
this.y = 0;
this.speed = 0.5;
this.sprite = sprite;
this.status = EAnimStatus.UP;
+ this.stop = false;
+
},
- animrun: function(){
+ runAnim: function(){
if(this.cnt <= this.maxY){
this.status = EAnimStatus.DOWN;
}
else if(this.cnt >= this.minY){
this.status = EAnimStatus.UP;
-
}
+ if(this.stop)return;
if(this.status == EAnimStatus.UP){
this.sprite.y -= this.speed;
this.cnt -= this.speed;
+ this.cntUp -= this.speed;
}
else if(this.status == EAnimStatus.DOWN){
this.sprite.y += this.speed;
this.cnt += this.speed;
+ this.cntDown += this.speed;
}
- }
+ if(this.cnt != (this.cntUp + this.cntDown)){
+ console.log(this.cnt + "@" + this.cntUp + ":" + this.cntDown);
+ }
+ // console.log(this.cnt);
+ },
+ startAnim:function(){
+ // console.log("start:" + this.cnt);
+ this.stop = false;
+ },
+ stopAnim: function(){
+ this.sprite.y -= this.cnt;
+ this.cntUp = 0;
+ this.cntDown = 0;
+ this.cnt = 0;
+ this.stop = true;
+ },
});
\ No newline at end of file
this.spriteArray = [];
this.id = guid();
this.mainIndex = 0;
+ this.shadowIndex = 0;
},
addChild:function(sprite, index, attr){
this.add(sprite, index, attr);
// },
/**
attr:
- mainIndex:true/false
+ mainIndexFlg:true/false
+ shadowIndexFlg:true/false
type:body/tweet
+
*/
add : function(sprite, index, attr){
if(attr === undefined)attr = {};
if(attr.mainIndexFlg){
this.mainIndex = index;
}
+ if(attr.shadowIndexFlg){
+ this.shadowIndex = index;
+ }
// this.spriteArray.push(sprite);
},
remove: function (sprite){
spr.y += y;
}
},
+ getMainSprite: function(){
+ return this.spriteArray[this.mainIndex];
+ },
+ getShadowSprite: function(){
+ return this.spriteArray[this.shadowIndex];
+ },
+ getMainShadowMarginY: function(){
+ return Math.round(this.getMainSprite().y - this.getShadowSprite().y);
+ },
getX: function(){
return Math.round(this.spriteArray[this.mainIndex].x,2) - this.spriteArray[this.mainIndex].baseX;
},
spr.y = y + spr.baseY;
}
},
+ addBodyY: 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 == "body" || spr.type == "budge"){
+ this.spriteArray[i].y += y;
+ }
+ }
+ },
setFixBudgeLeft: function (index){
this.spriteArray[index].x = this.spriteArray[this.mainIndex].x + this.spriteArray[this.mainIndex].width / 3 * 2;
this.spriteArray[index].scaleX = 1;
tlQueueLength:function(){
return this.spriteArray[this.mainIndex].tl.queue.length;
},
- animation: function(){
+ formRunAnimation: function(){
+ if(this.getMainShadowMarginY() < -8){
+ this.addBodyY(+1);
+ }
+ else if(this.getMainShadowMarginY() > 0){
+ this.addBodyY(-1);
+ }
+ for(var i=0;i<this.spriteArray.length;i++){
+ if(this.spriteArray[i] === undefined)continue;
+ var spr = this.spriteArray[i];
+ if(spr.type == "body" || spr.type == "budge"){
+ spr.anim.runAnim();
+ }
+ }
+ },
+ formStartAnimation: 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" || spr.type == "budge"){
+ spr.anim.startAnim();
+ }
+ }
+ },
+ formStopAnimation: 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" || spr.type == "budge"){
- spr.anim.animrun();
+ spr.anim.stopAnim();
}
}
},
yukkuri.action.setStatus(EAction.MOVE_TO_COMMAND);
return;
}
+ if(yukkuri.isSleep()){
+ yukkuri.action.setStatus(EAction.SLEEP_START);
+ return;
+ }
+ else if(yukkuri.getUnun() >= 80){
+ yukkuri.action.setStatus(EAction.UNUN_START);
+ return;
+ }
if(yukkuri.isItemsMax() && yukkuri.isPlace()){
yukkuri.action.targetNode = yukkuri.getPlace();
return;
}
- if(yukkuri.isSleep()){
- yukkuri.action.setStatus(EAction.SLEEP_START);
- return;
- }
-
- else if(yukkuri.getUnun() >= 80){
- yukkuri.action.setStatus(EAction.UNUN_START);
- return;
- }
if(!yukkuri.isItemsMax() && yukkuri.isPlace()){
this.runUnun();
this.runSleep();
this.runAddress();
- this.formSprite.animation();
+ this.runAnimation();
+ // this.animation();
}
// }catch(e){
act: function(){
this.action.act();
},
-
+ runAnimation: function(){
+ this.formSprite.formRunAnimation();
+ },
animation: function(){
- this.formSprite.animation();
+ this.formSprite.formStartAnimation();
// var frame = 10;
// frame -= plusFrameScale(frame, this.getMyScale()) / 2;
// var move = 5;
},
runSleep: function(){
if(this.action.getStatus() != EAction.SLEEP_START && this.action.getStatus() != EAction.SLEEP_WAIT){
- if(this.age%80 === 0 && this.age !== 0)this.param.sleep++;
+ if(this.age%80 === 0 && this.age !== 0)this.param.sleep += 1;
if(this.param.sleep >= 100){
this.param.sleep = 100;
}
// this.imgBody.tl.unloop();
// this.imgGroup.tl.unloop();
// this.imgBody.y = 0;
-
+ this.formSprite.formStopAnimation();
},
tlResume: function(){
// this.imgBody.tl.resume();
this.kukis[3] = new Kuki(this, -5, 5);
this._tweet = new TTweet(this, 148, 64);
- this.formSprite.addChild(this.shadow,0,{type:"shadow",scaleValue:this.myScaleY});
+ this.formSprite.addChild(this.shadow,0,{type:"shadow",shadowIndexFlg:true,scaleValue:this.myScaleY});
this.formSprite.addChild(this, 1, {
mainIndexFlg:true,
type : "body",
// 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 + 100, PALYER_INIT_Y + 100, EGrow.ADULT);
+ //new Reimu(PALYER_INIT_X + 100, PALYER_INIT_Y + 100, 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);
// new Reimu(PALYER_INIT_X + 250, PALYER_INIT_Y + 400, EGrow.BABY);
+++ /dev/null
-var Animation = enchant.Class.create({
- initialize: function (sprite){
- this.cnt = 0;
- this.maxY = -4;
- this.minY = 0;
- this.y = 0;
- this.speed = 0.5;
- this.sprite = sprite;
- this.status = EAnimStatus.UP;
- },
- animrun: function(){
- if(this.cnt <= this.maxY){
- this.status = EAnimStatus.DOWN;
- }
- else if(this.cnt >= this.minY){
- this.status = EAnimStatus.UP;
-
- }
- if(this.status == EAnimStatus.UP){
- this.sprite.y -= this.speed;
- this.cnt -= this.speed;
- }
- else if(this.status == EAnimStatus.DOWN){
- this.sprite.y += this.speed;
- this.cnt += this.speed;
- }
- }
-});
\ No newline at end of file
+++ /dev/null
-var FormSprite = enchant.Class.create({
- initialize: function (){
- this.spriteArray = [];
- 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]);
- }
- },
- /**
- attr:
- mainIndex:true/false
- type:body/tweet
- */
- add : function(sprite, index, attr){
- if(attr === undefined)attr = {};
- this.spriteArray[index] = sprite;
- this.spriteArray[index].type = attr.type;
- this.spriteArray[index].scaleValue = attr.scaleValue;
- if(attr.mainIndexFlg){
- this.mainIndex = index;
- }
- // this.spriteArray.push(sprite);
- },
- remove: function (sprite){
- this.spriteArray.remove(sprite);
- },
- addX: function(x){
- for(var i=0;i<this.spriteArray.length;i++){
- var spr = this.spriteArray[i];
- spr.x += x;
- }
- },
- addY: function(y){
- for(var i=0;i<this.spriteArray.length;i++){
- var spr = this.spriteArray[i];
- spr.y += y;
- }
- },
- getX: function(){
- return Math.round(this.spriteArray[this.mainIndex].x,2) - this.spriteArray[this.mainIndex].baseX;
- },
- getY: function(){
- return Math.round(this.spriteArray[this.mainIndex].y,2) - this.spriteArray[this.mainIndex].baseY;
- },
- setX: function(x){
- for(var i=0;i<this.spriteArray.length;i++){
- var spr = this.spriteArray[i];
- spr.x = x + spr.baseX;
- }
- },
- setY: function(y){
- for(var i=0;i<this.spriteArray.length;i++){
- var spr = this.spriteArray[i];
- spr.y = y + spr.baseY;
- }
- },
- formScaleX: function(x){
- for(var i=0;i<this.spriteArray.length;i++){
- 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++){
- var spr = this.spriteArray[i];
- if(spr.type == "tweet")continue;
- spr.scaleY = y;
- }
- },
- // tlTween:function(params){
- // console.log("tlTween");
- // for(var i=0;i<this.spriteArray.length;i++){
- // var spr = this.spriteArray[i];
- // spr.tl.tween(params);
- // }
- // },
- tlMoveBy:function(x, y, time, eventFunctions){
- var self = this;
- for(var i=0;i<this.spriteArray.length;i++){
- 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),
- time: time,
- easing: enchant.Easing.SIN_EASEINOUT
- };
- if(eventFunctions !== undefined && i == this.mainIndex){
- for(var key in eventFunctions){
- params[key] = eventFunctions[key];
- }
- }
- spr.tl.tween(params);
- }
- },
- 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++){
- var spr = this.spriteArray[i];
- spr.tl.moveTo(x, y, time, easing);
- }
- },
- tlQueueLength:function(){
- return this.spriteArray[this.mainIndex].tl.queue.length;
- },
- animation: function(){
- for(var i=0;i<this.spriteArray.length;i++){
- var spr = this.spriteArray[i];
- if(spr.type == "body"){
- spr.anim.animrun();
- }
- }
- },
- scale: function(_scaleX,_scaleY){
- for(var i=0;i<this.spriteArray.length;i++){
- var spr = this.spriteArray[i];
- if(spr.type == "tweet")continue;
- spr.scale(_scaleX, _scaleY);
- }
- },
-});
\ No newline at end of file