JAVASCRIPT 90
CPlayer.js Guest on 14th April 2021 11:36:44 AM
  1. function CPlayer(oParentContainer){
  2.     var _oTeamSprite;
  3.     var _oPlayer;
  4.     var _oSpriteSheetPlayer = null;
  5.     var _oAnimation = null;
  6.    
  7.     var _oContainer = oParentContainer;
  8.    
  9.     this._init = function(){
  10.        
  11.     };
  12.    
  13.     this.showIdle = function(iX, iY, szSpriteSelected){
  14.         _oTeamSprite = {  
  15.             images: [s_oSpriteLibrary.getSprite(szSpriteSelected+"_idle")],
  16.             framerate: 10,
  17.             // width, height & registration point of each sprite
  18.             frames: {width: PLAYER_WIDTH, height: PLAYER_HEIGHT, regX: PLAYER_WIDTH/2, regY: PLAYER_WIDTH},
  19.             animations: {idle:[0, 23, "idle"]}
  20.         };
  21.         _oSpriteSheetPlayer = new createjs.SpriteSheet(_oTeamSprite);
  22.         if(_oAnimation === null){
  23.             _oAnimation = new createjs.Sprite(_oSpriteSheetPlayer, "idle");
  24.         }else{
  25.             _oAnimation.spriteSheet = _oSpriteSheetPlayer;
  26.         }
  27.         _oAnimation.x = iX;
  28.         _oAnimation.y = iY;
  29.         _oAnimation.currentAnimationFrame = 0;
  30.         _oContainer.addChild(_oAnimation);
  31.     };
  32.    
  33.     this.showShot = function(iX, iY, szSpriteSelected){
  34.         _oTeamSprite = {  
  35.             images: [s_oSpriteLibrary.getSprite(szSpriteSelected+"_shot")],
  36.             framerate: 15,
  37.             // width, height & registration point of each sprite
  38.             frames: {width: PLAYER_WIDTH, height: PLAYER_HEIGHT, regX: PLAYER_WIDTH/2, regY: PLAYER_WIDTH},
  39.             animations: {idle:[0, 20, "idle"]}
  40.         };
  41.         _oSpriteSheetPlayer = new createjs.SpriteSheet(_oTeamSprite);
  42.         if(_oAnimation === null){
  43.             _oAnimation = new createjs.Sprite(_oSpriteSheetPlayer, "idle");
  44.         }else{
  45.             _oAnimation.spriteSheet = _oSpriteSheetPlayer;
  46.         }
  47.         _oAnimation.x = iX;
  48.         _oAnimation.y = iY;
  49.         _oAnimation.currentAnimationFrame = 0;
  50.         _oContainer.addChild(_oAnimation);
  51.     };
  52.    
  53.     this.changeAlpha = function(){
  54.         _oAnimation.alpha = 0.5;
  55.     };
  56.    
  57.     this.getFrame = function(){
  58.         return _oAnimation.currentFrame;
  59.     };
  60.    
  61.     this.unload = function(){
  62.         _oPlayer = null;
  63.         _oContainer.removeAllChildren();
  64.     };
  65.    
  66.     s_oPlayer = this;
  67.    
  68.     this._init(oParentContainer);
  69.    
  70. }
  71. s_oPlayer = null;

Paste-bin is for source code and general debugging text.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste

Login or Register to edit or fork this paste. It's free.