enchant();
//////////////////////////////////////
+/*
+ CanvasLayer初期化後にcanvasのコンテキストを操作する
+*/
+// var initCanvas = CanvasLayer.prototype.initialize;
+
+// CanvasLayer.prototype.initialize = function() {
+// initCanvas.call(this);
+// console.log("canvas");
+
+// // 拡大時の処理をNearest Neighbor方式に切り替え
+// // ただしChromeとFireFoxでのみ動作
+// this.context.imageSmoothingEnabled = false;
+// this.context.webkitImageSmoothingEnabled = false;
+// this.context.mozImageSmoothingEnabled = false;
+// };
//global
var ctl = null;
var mangIcon = null;
START: 0,
END: 1,
};
-
+var EGrow = {
+ ADULT : 0,
+ SUBADULT : 1,
+ CHILD : 2,
+ BABY : 3,
+};
var ObjSprite = enchant.Class.create(enchant.Sprite,{
initialize: function (w, h){
getY: function(){
return this.y;
},
+ getWidth: function(){
+ return this.width;
+ },
+ getHeight: function(){
+ return this.height;
+ },
removeAll: function(){
this.remove();
ctl.removeObj(this);
}
return this.tween(params);
};
+function plusFrameScale(frame, scale){
+ return (frame/2) * (1 - scale)
+}
}
if(this.yukkuri.imgGroup.tl.queue.length === 0){
var frame = 200;
+ frame += plusFrameScale(frame, this.yukkuri.getMyScale());
if(this.isMoving){
this.isMoving = false;
this.status = EAction.THINK;
yukkuri.vy = node.y - yukkuri.getY() - yukkuri.getHeight() / 2 + node.height / 2;
var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
var frame = distance + distance/5 + 1;
+ frame += plusFrameScale(frame, this.yukkuri.getMyScale());
yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
yukkuri.reverse();
yukkuri.vy = node.y - yukkuri.getY();
var distance = (Math.abs(yukkuri.vx) + Math.abs(yukkuri.vy)) / 2;
var frame = distance + 1;
+ frame += plusFrameScale(frame, this.yukkuri.getMyScale());
+
yukkuri.moveBy(yukkuri.vx, yukkuri.vy, frame, {
"onactionstart": this.onactionstart(this),
"onactiontick": this.onactiontick(this),
yukkuri.vy = node.y + node.height - yukkuri.getY() - 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());
+
yukkuri.direction = yukkuri.vx > 0 ? EDirection.RIGHT : EDirection.LEFT;
yukkuri.reverse();
// }
});
var Okazari = enchant.Class.create(enchant.Sprite,{
- initialize: function(){
+ initialize: function(yukkuri){
this.classname = "Okazari";
enchant.Sprite.call(this, 64, 64);
this.image = game.assets[EResPath.OKAZARI];
+ this.yukkuri = yukkuri;
this.x = -CHARA_WIDTH / 2;
- this.y = -12 - CHARA_HEIGHT / 2;
+ this.y = -CHARA_HEIGHT / 2 - yukkuri.getWidth()/6;
+ },
+ getWidth: function(){
+ return this.width;
+ // return this.width * this.yukkuri.myScaleX;
+ },
+ getHeight: function(){
+ return this.height;
+ // return this.height * this.yukkuri.myScaleY;
}
});
var Address = enchant.Class.create({
});
var Yukkuri = enchant.Class.create(ObjSprite,{
- initialize: function(x, y){
+ initialize: function(x, y, grow){
ObjSprite.call(this, 64, 64);
+ this.grow = grow;
+ if(grow == EGrow.ADULT){
+ this.myScaleX = 1;
+ this.myScaleY = 1;
+ }
+ else if(grow == EGrow.SUBADULT){
+ this.myScaleX = 0.8;
+ this.myScaleY = 0.8;
+ }
+ else if(grow == EGrow.CHILD){
+ this.myScaleX = 0.6;
+ this.myScaleY = 0.6;
+ }
+ else if(grow == EGrow.BABY){
+ this.myScaleX = 0.4;
+ this.myScaleY = 0.4;
+ }
+
// ctl.game.rootScene.addEventListener('touchstart', this.touchstart);
this.classname = "Yukkuri";
this.addressBook = {};
this.place = null;
},
runEnterframe:function(){
- // this.imgGroup.x = 0;
- // return ;
try{
this.act();
if(this.isDead())return;
this.action.act();
},
animation: function(){
+
+ var frame = 10;
+ frame += plusFrameScale(frame, this.getMyScale());
+ var move = 5;
+ move -= plusFrameScale(move, this.getMyScale());
if(this.walkAnimationStatus == EWalkAnimation.END){
this.imgBody.y = 0;
- this.imgBody.tl.moveByEx(0, -5, 10, enchant.Easing.SWING, {
+ this.imgBody.tl.moveByEx(0, -move, frame, enchant.Easing.SWING, {
"onactionstart": function(e){
this.walkAnimationStatus = EWalkAnimation.START;
}
})
- .moveByEx(0, 5, 10, enchant.Easing.SWING,
+ .moveByEx(0, move, frame, enchant.Easing.SWING,
{
"onactionend": function(e){
this.walkAnimationStatus = EWalkAnimation.END;
this.imgBody.tl.loop();
}
},
+ getMyScale: function(){
+ return (this.myScaleX + this.myScaleY) / 2;
+ },
getWidth: function(){
- return this.width;
+ return this.width * this.myScaleX;
},
getHeight: function(){
- return this.height;
+ return this.height * this.myScaleY;
},
getX: function(){
return this.imgGroup.x;
}
});
var Marisa = enchant.Class.create(Yukkuri,{
- initialize: function(x, y){
- Yukkuri.call(this,x,y);
+ initialize: function(x, y, grow){
+ Yukkuri.call(this,x,y, grow);
this.classname = "Marisa";
// var xml = this.loadParamsXML("./data/marisa/params.xml");
this.shadow = new enchant.Sprite(64, 64);
this.shadow.image = game.assets[EResPath.YUKKURI_SHADOW];
this.shadow.x = 0 + this.x;
- this.shadow.y = CHARA_HEIGHT / 16 + this.x;
+ this.shadow.y = this.getWidth() / 16 + this.x;
this.shadow.image._element.style.zIndex = 2;
this._style.zIndex = 5;
this.hear.y = -CHARA_HEIGHT / 2;
this.hear._style.zIndex = 0;
- this.okazari = new Okazari();
- this.okazari.image._element.style.zIndex = 1;
+ this.okazari = new Okazari(this);
// this.imgGroup._style.zIndex = 1;
+
this.imgGroup.addChild(this.shadow);
this.imgBody.addChild(this);
this.imgBody.addChild(this.face);
this.imgBody.addChild(this.hear);
this.imgBody.addChild(this.okazari);
+ 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.width/2;
- this.budge.y -= this.height/2;
+ this.budge.x -= this.getWidth()/2;
+ this.budge.y -= this.getHeight()/2;
+ this.budge.scale(this.myScaleX, this.myScaleX);
}
this.imgGroup.addChild(this.imgBody);
backgroundMap.addChild(this.imgGroup);
this.imgGroup.addChild(this._tweet);
this.imgGroup.x = x;
this.imgGroup.y = y;
+
this.animation();
this.action = new Action(this);
ctl.addObj(this);
+ // this.imgGroup.scale(_scaleX,_scaleX);
+ // this.scale(scale,scale);
+ },
+ myScale: function(_scaleX, _scaleY){
+ this.face.scale(_scaleX,_scaleY);
+ this.okazari.x = -32;
+ this.okazari.y = -32 - this.getWidth()/6;
+ this.okazari.scale(_scaleX,_scaleY);
+ this.hear.scale(_scaleX,_scaleY);
+ this.scale(_scaleX,_scaleY);
+ this.shadow.scale(_scaleX, _scaleY);
+
},
setFaceImage: function(eface){
var path = this.faceStatus[eface];
initialize: function(x, y){
// this.runEnterframe = function(){
// },
- Marisa.call(this, x, y);
+ Marisa.call(this, x, y, EGrow.ADULT);
this.classname = "Player";
ctl.setPlayer(this);
// this.removeEventListener('enterframe',this.runEnterframe);
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 + 200);
- new Marisa(PALYER_INIT_X + 800, PALYER_INIT_Y + 800);
- new Unun(100, 100);
+ 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 + 200, PALYER_INIT_Y + 200);
+ // new Marisa(PALYER_INIT_X + 800, PALYER_INIT_Y + 800);
+ // new Unun(100, 100);
// new Place("tree", PALYER_INIT_X, PALYER_INIT_Y - 50);
var touchX = 0;
+
game.rootScene.addEventListener('touchstart', function (e) {
game.touched = true;
var mang = mangTouch.get(ctl.getCurrentCommand());