Skip to content

Commit

Permalink
Merge pull request #86 from soltycabbage/feature/death-motion-returns
Browse files Browse the repository at this point in the history
Feature/death motion returns
  • Loading branch information
karihei committed Feb 14, 2014
2 parents 0c75a30 + 58ea594 commit fc07d8e
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 28 deletions.
15 changes: 1 addition & 14 deletions app/beamQuest/ctrl/mob/mob.js
Original file line number Diff line number Diff line change
Expand Up @@ -54,19 +54,6 @@ var Mob = function() {
*/
this.isPassive = true;

/**
* FFのアクティブタイムバトル的な。activeTimeUp以上で行動開始
* @type {number}
* @private
*/
this.activeTime_ = 0;

/**
* activeTimeがこの数値以上になったら攻撃等の動作を開始する
* @type {Number}
*/
this.activeTimeUp = 100;

/**
* 行動中(攻撃モーション中 etc)ならtrue
* @type {Boolean}
Expand Down Expand Up @@ -111,7 +98,7 @@ Mob.prototype.update = function() {
if (_.isEmpty(this.hateList) && this.startPos) {
// 敵対キャラを殺し尽くしたら元の位置に戻っていく・・・
this.isActive_ = false;
this.moveTo(this.startPos, 50);
this.attackCancel();
}
} else if (targetEntity) { // ターゲットが同じマップ内にいるなら攻撃を仕掛ける
this.attackTo(targetEntity);
Expand Down
36 changes: 25 additions & 11 deletions public/js/src/entity/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,18 @@ bq.entity.Entity = cc.Sprite.extend({
}
},

/**
* @param {string} key
* @returns {bq.Animate}
*/
getAnimationByKey: function(key) {
if (this.animations[key] ) {
return this.animations[key];
} else {
cc.log(key + " is not found");
return null;
}
},

/**
*
Expand All @@ -185,11 +197,7 @@ bq.entity.Entity = cc.Sprite.extend({
*/
getAnimationByNameDirection: function(name, direction) {
var key = name + "_" + direction;
if ( this.animations[key] ) {
return this.animations[key];
} else {
cc.log(key + " is not found");
}
return this.getAnimationByKey(key);
},

/**
Expand All @@ -212,13 +220,9 @@ bq.entity.Entity = cc.Sprite.extend({
this.currentDirection = direction;

var animation = this.getAnimationByNameDirection(state,direction);
animation.setTag('walk_');
animation.setTag('walk');

// すでにactionManagerの管理下にある歩行アニメーションを削除
var oldAnimation = this.getActionByTag('walk_');
if (oldAnimation) {
this.stopAction(oldAnimation);
}
this.stopForeverAnimation();
this.runAction(animation);
},

Expand All @@ -239,6 +243,16 @@ bq.entity.Entity = cc.Sprite.extend({
}
},

/**
* 常に動いているアニメーション(歩行アニメーションとか)を止める
*/
stopForeverAnimation: function() {
var walkAnimation = this.getActionByTag('walk');
if (walkAnimation) {
this.stopAction(walkAnimation);
}
},

/**
* @private
*/
Expand Down
32 changes: 30 additions & 2 deletions public/js/src/entity/player.js
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,36 @@ bq.entity.Player = bq.entity.Entity.extend({
kill: function(){
this.currentState = bq.entity.EntityState.Mode.death;
bq.MessageLog.getInstance().addSystemMsg('あなたは死にました。復活地点に戻ります。');
this.stopForeverAnimation();

// 死亡モーション*くるくるまわってぱたっと倒れる
var frameCache = cc.SpriteFrameCache.getInstance();
var rotateFrames = this.getKeyFrameMap_()['rotate'];
var rotateAnimation = cc.Animation.create();
rotateAnimation.setDelayPerUnit(0.03);
rotateAnimation.setLoops(5);
_.forEach(rotateFrames, function(rotateFrame) {
rotateAnimation.addSpriteFrame(frameCache.getSpriteFrame(rotateFrame));
});
var deathFrames = this.getKeyFrameMap_()['death'];
var deathAnimation = cc.Animation.create();
deathAnimation.setDelayPerUnit(0.1);
_.forEach(deathFrames, function(deathFrame) {
deathAnimation.addSpriteFrame(frameCache.getSpriteFrame(deathFrame));
});

var fadeOut = cc.FadeOut.create(0.8);
var blink = cc.Blink.create(1, 50);
var delay = cc.DelayTime.create(1);
var callFunc = cc.CallFunc.create(this.respawn.bind(this));
this.runAction(cc.Sequence.create(cc.Spawn.create(fadeOut, blink), callFunc));
this.runAction(cc.Sequence.create(
cc.Animate.create(rotateAnimation), // くるくるまわって
cc.Animate.create(deathAnimation), // ぱたっと倒れて
delay, // 1秒待って
cc.Spawn.create(fadeOut, blink), // 点滅しながら消えていく
delay,
callFunc
));
},

/** @override */
Expand Down Expand Up @@ -200,7 +226,9 @@ bq.entity.Player = bq.entity.Entity.extend({
step_top: ["b4_4.png", "b4_5.png", "b4_6.png", "b4_7.png"],
step_topleft: ["b5_4.png", "b5_5.png", "b5_6.png", "b5_7.png"],
step_left: ["b6_4.png", "b6_5.png", "b6_6.png", "b6_7.png"],
step_bottomleft: ["b7_4.png", "b7_5.png", "b7_6.png", "b7_7.png"]
step_bottomleft: ["b7_4.png", "b7_5.png", "b7_6.png", "b7_7.png"],
rotate: ["b0_0.png", "b1_0.png","b2_0.png", "b3_0.png","b4_0.png", "b5_0.png","b6_0.png", "b7_0.png"],
death: ["playerMisc0_0.png","playerMisc0_1.png","playerMisc0_2.png","playerMisc0_3.png"]
};
},

Expand Down
3 changes: 3 additions & 0 deletions public/js/src/resource.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ var s_ImgPlayerWalking = 'res/img/player/walk.png';
var s_ImgBeam0 = 'res/img/beam/star.png';
var s_ImgSimpleBeam = 'res/img/beam/simple.png';
var s_ImgSmoke0 = 'res/img/beam/smoke.png';
var s_ImgPlayerMisc = 'res/img/player/misc.png';

// tmx
// TODO s_Tmx, s_Tile はじまりにへんこー
Expand All @@ -28,6 +29,7 @@ var s_SmallVillageMapSet = 'res/map/tile_small_village.png';
// plist
var s_PlistPlayerWalking = 'res/img/player/walk.plist';
var s_PlistSimpleBeam = 'res/img/beam/simple.plist';
var s_PlistPlayerMisc = 'res/img/player/misc.plist';

// sounds
var s_BgmField = 'res/sounds/Field.m4a';
Expand All @@ -50,6 +52,7 @@ var g_resources = [
//plist
{type: 'plist', src:s_PlistPlayerWalking},
{type: 'plist', src:s_PlistSimpleBeam},
{type: 'plist', src:s_PlistPlayerMisc},

//fnt

Expand Down
2 changes: 1 addition & 1 deletion public/js/src/scene/login.js
Original file line number Diff line number Diff line change
Expand Up @@ -85,8 +85,8 @@ bq.scene.LoginLayer = cc.Layer.extend({
// init frame cache
var frameCache = cc.SpriteFrameCache.getInstance();
frameCache.addSpriteFrames(s_PlistPlayerWalking, s_ImgPlayerWalking);
// FIXME ハイパー違和感2、誰か直して〜
frameCache.addSpriteFrames(s_PlistSimpleBeam, s_ImgSimpleBeam);
frameCache.addSpriteFrames(s_PlistPlayerMisc, s_ImgPlayerMisc);

var player = new bq.entity.Player();
var hud = bq.Hud.getInstance();
Expand Down
74 changes: 74 additions & 0 deletions public/res/img/player/misc.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple Computer//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>frames</key>
<dict>
<key>playerMisc0_0.png</key>
<dict>
<key>frame</key>
<string>{{0,0},{32,32}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{32,32}}</string>
<key>sourceSize</key>
<string>{32,32}</string>
</dict>
<key>playerMisc0_1.png</key>
<dict>
<key>frame</key>
<string>{{32,0},{32,32}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{32,32}}</string>
<key>sourceSize</key>
<string>{32,32}</string>
</dict>
<key>playerMisc0_2.png</key>
<dict>
<key>frame</key>
<string>{{64,0},{32,32}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{32,32}}</string>
<key>sourceSize</key>
<string>{32,32}</string>
</dict>
<key>playerMisc0_3.png</key>
<dict>
<key>frame</key>
<string>{{96,0},{32,32}}</string>
<key>offset</key>
<string>{0,0}</string>
<key>rotated</key>
<false/>
<key>sourceColorRect</key>
<string>{{0,0},{32,32}}</string>
<key>sourceSize</key>
<string>{32,32}</string>
</dict>
</dict>
<key>metadata</key>
<dict>
<key>format</key>
<integer>2</integer>
<key>realTextureFileName</key>
<string>misc.png</string>
<key>size</key>
<string>{128,32}</string>
<key>smartupdate</key>
<string>$TexturePacker:SmartUpdate:bea201787e72d76f7695454f2a3a9ad7:9ba030ca501736ff917dcada10220ec5:98bb4e62e9d2bd9a6870f48e0c4f6d1c$</string>
<key>textureFileName</key>
<string>misc.png</string>
</dict>
</dict>
</plist>
Binary file added public/res/img/player/misc.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.

0 comments on commit fc07d8e

Please sign in to comment.