Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Game_AI.prototype.executeSlideHorizontaly = function(a,b) {
- // a = speed
- // b = total time
- var initialPos = -400;
- var finalPos = this._personality.xOffset;
- this._value = 0;
- // begin loop
- if(this._value < b ){
- this._value ++
- // first condition : if x is inferior than the finalPos
- if(this.aiSprite.x < finalPos){
- this.aiSprite.x += a;
- // second condition : if value is reaching is limit
- if(this._value >= b){
- this.aiSprite.x = finalPos;
- }
- }
- // third condition : if the x = finalPos AND time value is not b
- // return the sprite to his initiat position if asked.
- if(this.aiSprite.x >= finalPos && !this._value >= b){
- this.aiSprite.x -= a;
- // last condition : if the pose is inferior or equal to initial pos
- // or time limit is reached.
- if(this.aiSprite.x <= initialPos || this._value >= b){
- this.aiSprite.x = initialPos;
- }
- }
- }
- // deactivate the flag when finish
- this.setEffectFlag(false);
- };
Advertisement
Add Comment
Please, Sign In to add comment