Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

たまに自分の位置が他人から見た位置と異なることがあるのを修正 #66

Merged
merged 1 commit into from
Jan 29, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions public/js/src/entity/entity.js
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,36 @@ bq.entity.Entity = cc.Sprite.extend({
bq.baseLayer.addChild(label, bq.config.tags.EXP_LABEL);
},

/**
* 指定位置に移動する
* @param {cc.p} pos
*/
moveTo: function(pos) {
var moveActTag = 'entity_move_' + this.name;
var move = cc.MoveTo.create(0.2, pos);
if (this.currentState == bq.entity.EntityState.Mode.walking) {
var runningMoveAct = this.getActionByTag(moveActTag);
if (runningMoveAct) {
this.stopAction(runningMoveAct);
delete runningMoveAct;
}

// 走ってる状態だったら移動だけ(アニメーションは更新しない)
move.setTag(moveActTag);
this.runAction(move);
} else {
this.updateAnimation(bq.entity.EntityState.Mode.walking, null);
// 移動したあと急に止めるとアニメーションが不自然になるので少し遅延を入れる
var delay = cc.DelayTime.create(0.2);
var changeAnime = cc.CallFunc.create(function () {
this.updateAnimation(bq.entity.EntityState.Mode.stop, null)
}.bind(this));

var act = cc.Sequence.create([move, delay, changeAnime]);
this.runAction(act);
}
},

/**
* 死にモーション
*/
Expand Down
21 changes: 3 additions & 18 deletions public/js/src/entityManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -57,26 +57,11 @@ bq.EntityManager = cc.Class.extend({
* @param {bq.model.PlayerMove} moveData
*/
moveTo: function(moveData) {
if (!this.otherPlayers_[moveData.userId]) {
var otherPlayer = this.otherPlayers_[moveData.userId];
if (!otherPlayer) {
this.createOtherPlayer(moveData);
} else {
var otherPlayer = this.otherPlayers_[moveData.userId];
var move = cc.MoveTo.create(0.2, cc.p(moveData.x, moveData.y));

if (otherPlayer.currentState == bq.entity.EntityState.Mode.walking) {
// 走ってる状態だったら移動だけ(アニメーションは更新しない)
otherPlayer.runAction(move);
} else {
otherPlayer.updateAnimation(bq.entity.EntityState.Mode.walking, null);
// 移動したあと急に止めるとアニメーションが不自然になるので少し遅延を入れる
var delay = cc.DelayTime.create(0.2);
var changeAnime = cc.CallFunc.create(function () {
otherPlayer.updateAnimation(bq.entity.EntityState.Mode.stop, null)
});

var act = cc.Sequence.create([move, delay, changeAnime]);
otherPlayer.runAction(act);
}
otherPlayer.moveTo(cc.p(moveData.x, moveData.y));
}
},

Expand Down