mirror of
https://github.com/logsol/chuck.js.git
synced 2026-05-11 10:37:34 +00:00
control features implemented
This commit is contained in:
parent
8d0ff1a929
commit
c2b0baaea2
10 changed files with 213 additions and 63 deletions
|
|
@ -1,7 +1,7 @@
|
|||
Chuck.Player = function(engine, repository) {
|
||||
this._engine = engine;
|
||||
this._repository = repository;
|
||||
this._standing;
|
||||
this._standing = false;
|
||||
this._doll;
|
||||
this._mc;
|
||||
this._currentAnimationState = 'stand';
|
||||
|
|
@ -47,18 +47,18 @@ Chuck.Player.prototype.isStanding = function() {
|
|||
|
||||
Chuck.Player.prototype.move = function(direction) {
|
||||
this._moveDirection = direction;
|
||||
|
||||
|
||||
switch(true) {
|
||||
case direction == this._lookDirection && this.isStanding():
|
||||
this._doll.move(direction, Settings.RUN_SPEED);
|
||||
this._doll.move(direction, Chuck.Settings.RUN_SPEED);
|
||||
break;
|
||||
|
||||
case !this.isStanding():
|
||||
this._doll.move(direction, Settings.FLY_SPEED);
|
||||
this._doll.move(direction, Chuck.Settings.FLY_SPEED);
|
||||
break;
|
||||
|
||||
default:
|
||||
this._doll.move(direction, Settings.WALK_SPEED);
|
||||
this._doll.move(direction, Chuck.Settings.WALK_SPEED);
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
@ -107,7 +107,7 @@ Chuck.Player.prototype._animate = function(type) {
|
|||
return;
|
||||
}
|
||||
|
||||
this._mc.gotoAndPlay(type);
|
||||
//this._mc.gotoAndPlay(type);
|
||||
|
||||
this._currentAnimationState = type;
|
||||
}
|
||||
|
|
@ -120,15 +120,15 @@ Chuck.Player.prototype._calculateWalkAnimation = function() {
|
|||
}
|
||||
|
||||
Chuck.Player.prototype.look = function(x, y) {
|
||||
var degree = Math.atan2(Settings.STAGE_WIDTH / 2 - x, Settings.STAGE_HEIGHT / 2 - 25 - y) / (Math.PI / 180);
|
||||
var degree = Math.atan2(Chuck.Settings.STAGE_WIDTH / 2 - x, Chuck.Settings.STAGE_HEIGHT / 2 - 25 - y) / (Math.PI / 180);
|
||||
var lastLookDirection = this._lookDirection;
|
||||
|
||||
if (x < Settings.STAGE_WIDTH / 2) {
|
||||
if (x < Chuck.Settings.STAGE_WIDTH / 2) {
|
||||
this._mc.scaleX = -1;
|
||||
this._lookDirection = -1;
|
||||
degree = (-45 + degree / 2);
|
||||
this._mc.head.rotation = degree;
|
||||
} else if (x >= Settings.STAGE_WIDTH / 2) {
|
||||
} else if (x >= Chuck.Settings.STAGE_WIDTH / 2) {
|
||||
this._mc.scaleX = 1;
|
||||
this._lookDirection = 1;
|
||||
degree = (45 + -degree / 2) - 90;
|
||||
|
|
@ -152,7 +152,7 @@ Chuck.Player.prototype._isWalking = function() {
|
|||
// called by CollisionDetection
|
||||
Chuck.Player.prototype.onFootSensorDetection = function(isColliding) {
|
||||
if(isColliding) {
|
||||
if(this._doll.getBody().GetLinearVelocity().y < -Settings.JUMP_SPEED && !this.isStanding()) {
|
||||
if(this._doll.getBody().GetLinearVelocity().y < -Chuck.Settings.JUMP_SPEED && !this.isStanding()) {
|
||||
return;
|
||||
}
|
||||
this.setStanding(true);
|
||||
|
|
@ -167,7 +167,7 @@ Chuck.Player.prototype.onFootSensorDetection = function(isColliding) {
|
|||
}
|
||||
|
||||
Chuck.Player.prototype.update = function() {
|
||||
this._mc.head.y = this._mc.head_posmask.y;
|
||||
//this._mc.head.y = this._mc.head_posmask.y;
|
||||
|
||||
if (this._doll.getBody().GetLinearVelocity().x == 0 && this._isWalking()) {
|
||||
this.stop();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue