From 12a2e2452ba96947937601432c3c8ad24e94eb0a Mon Sep 17 00:00:00 2001 From: nagoling <> Date: Sat, 12 Oct 2013 16:30:55 +0900 Subject: [PATCH] update grow pattern --- class.js | 6 +++ ctrl.js | 12 ++--- data/okazari.png | Bin 1258 -> 1167 bytes main.js | 133 ++++++++++++++++++++++++++++++++++++++++++++++--------- 4 files changed, 124 insertions(+), 27 deletions(-) diff --git a/class.js b/class.js index d51a906..896af24 100644 --- a/class.js +++ b/class.js @@ -236,6 +236,12 @@ var Box = enchant.Class.create(enchant.Sprite, { getY : function(){ return this.y; }, + getWidth: function(){ + return this.width; + }, + getHeight: function(){ + return this.height; + }, touchstart:function(self){ return function(e){ if(typeof e === "undefined")return; diff --git a/ctrl.js b/ctrl.js index 4176de0..5d5afed 100644 --- a/ctrl.js +++ b/ctrl.js @@ -44,8 +44,8 @@ var Ctrl = enchant.Class.create({ isCollision : function (e, node){ var ex = e.x - ctl.backgroundMap.x; var ey = e.y - ctl.backgroundMap.y; - if(node.getX() <= ex && node.getX() + node.width >= ex - && node.getY() <= ey && node.getY() + node.height >= ey){ + if(node.getX() <= ex && node.getX() + node.getWidth() >= ex + && node.getY() <= ey && node.getY() + node.getHeight() >= ey){ return true; } return false; @@ -145,13 +145,13 @@ var WorldCursorTouchEvent = enchant.Class.create(ATouchEvent,{ continue; } if(node instanceof this.ctl.def.Yukkuri){ - nx -= node.width / 2; - ny -= node.height / 2; + nx -= node.getWidth() / 2; + ny -= node.getHeight() / 2; } if( nx <= tx - && (nx + node.width) >= tx + && (nx + node.getWidth()) >= tx && ny <= ty - && (ny + node.height) >= ty + && (ny + node.getHeight()) >= ty ){ // new BoxLabel(this.ctl,100, e.x, e.y); var box = new Box(this.ctl, node, e.x - ctl.backgroundMap.x, e.y - ctl.backgroundMap.y, 200, 200); diff --git a/data/okazari.png b/data/okazari.png index 8a774d6a5f0d88587a21f9e3c62f0e0f968f87b4..53e5c82201a5aa4c189e32ea8159d7e240d21dae 100644 GIT binary patch delta 383 zcmV-_0f7GM36BXOiBL{Q4GJ0x0000DNk~Le0000$0000$2m=5B0G+pi?6Dyn1Aje9 zL_t(|ob8rL62u?~MN`Ed?|<7iP7H!^=%s&=N>}&~1nuN`js>sI0EmZ>NJxw`Kq+I7 z0tK;8VFcV;j{+pdIbjLW0~V_=0V@axFpqEn5pfF8Mc6fs0I~>YI(jR4glG@;n#O>a zkT!XU8m$3}j6Ni9)(}ua`qL4n0DsuxBm(9E6vz;D?GpgxnL=#|yTUV+`*oC{}Zi2f!(kYK+6QQqN$6rnPRft3Q~ZWH?Y*k_7-Oh#S|#( z*9p;n1YWUzUkIT%q$2XYDrb0002+2m=5B0I;8*=&>Oj1AmxF zL_t(|obB1kZo)7WKv5*`lmGwQf-`s^2|GVmI%k2XD%9KO*n#%-nqK;dj(C#NvP>TN zF3gS59k+7eKE^pK)1EkQWmUM$x!zr1Zj5efT@_B1_#HUe6fXm3O1uf2C-FA$ofzGg zJp}ecjG5_EU^~R1-Q6G6cZKh~HGgK!p94RI`6jr&MXqt$U0jE`Z4(-}Cw$+X*C_&* zv!hK+^8}WVD)G4XCJ0>WNv+2vnYQO^nkMjwIy(391qYtP+Dpn;RcPEXa~yK#;?_mg z_oCh>o*Q7To>U`Dy^z3jQOhoAH%oK!jO{xDn)5DIqr15MjZ7>@UU$U&x_?8D?psp5 zqW$OP#>l{~ 0 ? EDirection.RIGHT : EDirection.LEFT; yukkuri.reverse(); @@ -837,6 +868,8 @@ window.onload = function(){ 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), @@ -951,6 +984,8 @@ window.onload = function(){ 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(); @@ -1109,12 +1144,21 @@ window.onload = function(){ // } }); 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({ @@ -1138,8 +1182,26 @@ window.onload = function(){ }); 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 = {}; @@ -1161,8 +1223,6 @@ window.onload = function(){ this.place = null; }, runEnterframe:function(){ - // this.imgGroup.x = 0; - // return ; try{ this.act(); if(this.isDead())return; @@ -1216,14 +1276,19 @@ window.onload = function(){ 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; @@ -1234,11 +1299,14 @@ window.onload = function(){ 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; @@ -1439,8 +1507,8 @@ window.onload = function(){ } }); 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"); @@ -1449,7 +1517,7 @@ window.onload = function(){ 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; @@ -1479,22 +1547,27 @@ window.onload = function(){ 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); @@ -1503,9 +1576,22 @@ window.onload = function(){ 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]; @@ -1516,7 +1602,7 @@ window.onload = function(){ 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); @@ -1616,12 +1702,17 @@ window.onload = function(){ 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()); -- 2.11.0