coineff

Programing/flash 2015.11.20 15:47 |

package objects.ObjectMgr
{
 import starling.animation.Juggler;
 import starling.core.Starling;
 import starling.display.MovieClip;
 import starling.display.Sprite;
 import starling.events.EnterFrameEvent;
 import starling.events.Event;
 
 import starling.animation.Juggler;
 import starling.utils.deg2rad;
 import com.greensock.TweenLite;
 import flash.system.System;
 /**
  * ...
  * @author searoopy
  */
 public class CoinEff extends BaseEff
 {
  
  static public var g_CoinEff:CoinEff = null;
  
  
  public function CoinEff(imageName:String)
  {
   
   g_CoinEff = this;
   
   super(imageName , 1 );
   
  }
  
 }

}

'Programing > flash' 카테고리의 다른 글

starling main frame  (0) 2015.11.20
starling moviebutton  (0) 2015.11.20
coineff  (0) 2015.11.20
baseEff  (0) 2015.11.20
objectMgr  (0) 2015.11.20
flash 용 app 인증 파일 만들기  (0) 2012.12.11
Posted by 패스맨

댓글을 달아 주세요

baseEff

Programing/flash 2015.11.20 15:44 |

package objects.ObjectMgr
{
 import com.distriqt.extension.notifications.events.GenericEvent;
 import flash.geom.Point;
 import starling.animation.Juggler;
 import starling.core.Starling;
 import starling.display.MovieClip;
 import starling.display.Sprite;
 import starling.events.EnterFrameEvent;
 import starling.events.Event;
 import UI.BigInt;
 
 import starling.animation.Juggler;
 import starling.utils.deg2rad;

 import com.greensock.TweenLite;
 import flash.system.System;
 import starling.utils.getTimer;
 
 import starling.text.TextField;
 
 import starling.utils.HAlign;
 import starling.utils.VAlign;
 import flash.geom.Rectangle;
 
 /**
  * ...
  * @author searoopy
  */
 public class BaseEff extends Sprite
 {
  //static public var g_DamageEff:DamageEff = null;
  
  public var m_mvEff:Vector.<MovieClip>;// = new vec;
  
  public var m_textEff:Vector.<TextField>;
  
  public const MAX_EFF_CNT:int = 16;
  
  protected var m_imageName:String ;
  
  public var m_Dir:Vector.<int>;
  
  private var m_type:int = 0;
  
  
  private var m_val:BigInt = new BigInt( 50);
  
  
  public function BaseEff( imageName:String , type:int = 0 )
  {
   super();

   this.addEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedStage);
   this.addEventListener(starling.events.Event.REMOVED_FROM_STAGE, onRemoveStage);

   
   m_imageName = imageName;
   
   m_type = type;
  }
  
  private function onAddedStage():void
  {
   this.removeEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedStage);
   
   init();

  }
  
   
  private function onRemoveStage():void
  {
   this.removeEventListener(starling.events.Event.REMOVED_FROM_STAGE, onRemoveStage);
   
   destroy();

  }
  
  public function init():void
  {
   m_mvEff = new Vector.<MovieClip>;
   m_Dir = new Vector.<int>;
   m_textEff = new Vector.<TextField>;

   var _tmv:MovieClip = null;
   var _text:TextField = null;
   for ( var i:int = 0; i < MAX_EFF_CNT; i++)
   {
    _tmv = new MovieClip( Assets.getAtlasTest().getTextures( m_imageName ), 15 );
    Assets.setCenterMC(_tmv);
    Starling.juggler.add(_tmv);
    _tmv.stop();
    _tmv.visible = false;
    addChild(_tmv);
    m_mvEff.push( _tmv ) ;
    
    m_Dir.push(0);
    
    
    _text = new TextField( 100, 70, "0", "Ubuntu", 30, 0xffffff );
    _text.pivotX = _text.width / 2;
    _text.pivotY = _text.height / 2;
    _text.x = 0; //130
    _text.y = 10;
    _text.hAlign = HAlign.CENTER;
    _text.vAlign = VAlign.CENTER;
    //_text.touchable = false;
    //m_textMoney.text = m_curStage.toString() +  " / " + m_maxStage.toString();// .1288';
    _text.visible = false;
    addChild(_text);
    
    m_textEff.push( _text);
   }
   
   this.addEventListener(EnterFrameEvent.ENTER_FRAME, onUpdate);

  }
  
  private function onUpdate():void
  {
   for ( var i:int = 0; i < MAX_EFF_CNT; i++)
   {
    if ( m_mvEff[i].visible == true)
    {
     //m_mvEff[i].x += m_Dir[i];
    }
    
   }

  }
  
  public function showEff( _x:int, _y:int , moveRan:Boolean = false ):void
  {
   for ( var i:int = 0; i < MAX_EFF_CNT; i++)
   {
    if ( m_mvEff[i].visible == false)
    {
     
     if ( moveRan == true)
     {
      var ran:Number = Math.random() ;
      if ( ran > 0.7)
      {
       m_Dir[i] = 1 + Math.random()*2;
      }
      else if (  ran > 0.3)
      {
       m_Dir[i] = -1 - Math.random()*2;
      }
      else
      {
       m_Dir[i] = Math.random()*2;
      }
     }
     
     
     //var text:TextField = m_textEff[i];
     //text.visible = true;
     //text.x = _x;
     //text.y = _y;
     
     /*
     if ( CoinTextEff.g_coinTextEff != null)
     {
      if( BigInt.compare(  LevelMgr.g_nBonusShowCoin , 0 ) > 0 )
       CoinTextEff.g_coinTextEff.showEff(  _x - 50, _y , LevelMgr.g_nBonusShowCoin.toString() );
     }
     */
     
     var tmv:MovieClip = m_mvEff[i];
     tmv.visible = true;
     //m_mvEff[i].x = 0;
     m_mvEff[i].x = _x;
     m_mvEff[i].y = _y ;
     //this.x = x;
     //this.y = y;
     tmv.stop();
     if ( m_type == 1 )
      tmv.currentFrame = Math.random() * 3;
     tmv.play();
     //tmv.addEventListener(Event.COMPLETE, onComplete);
     tmv.addEventListener(EnterFrameEvent.ENTER_FRAME, Delegate.sendParameters( onFrame ,  i , getTimer()  ) );
     break;
    }
   }
   
  }
  
  private function onFrame( idx:int , time:int ):void
  {
   if ( getTimer() - time > 300)
   {
    var mv:MovieClip = m_mvEff[idx ] as MovieClip;
    mv.removeEventListeners();
    mv.visible = false;
    
    //m_textEff[idx].visible = false;
    
    
   }
 
   
  }
  
  private function onComplete( event:Event ):void
  {
   //event.currentTarget.removeEventListeners();
   var mv:MovieClip = event.currentTarget as MovieClip;
   mv.removeEventListeners();
   mv.visible = false;
   
   
   if ( m_type == 1) // 코인일경우
   {
    if ( CoinTextEff.g_coinTextEff != null)
    {
     
     LevelMgr.addGameCoin( m_val );
     
     
     
     CoinTextEff.g_coinTextEff.showEff( this.x + mv.x , this.y + 20 , m_val.toString() );
    }
   }
  }
  
  
  public function destroy():void
  {
   if ( m_mvEff != null)
   {
    for ( var i:int = 0; i < MAX_EFF_CNT; i++)
    {
     Starling.juggler.remove(m_mvEff[i]);
     m_mvEff[i].removeFromParent(true);
     m_mvEff[i] = null;
    }
   }
   
   m_Dir = null;
   
   this.removeEventListeners();
   
   System.gc();
  }
  
  
 }

}

'Programing > flash' 카테고리의 다른 글

starling main frame  (0) 2015.11.20
starling moviebutton  (0) 2015.11.20
coineff  (0) 2015.11.20
baseEff  (0) 2015.11.20
objectMgr  (0) 2015.11.20
flash 용 app 인증 파일 만들기  (0) 2012.12.11
Posted by 패스맨

댓글을 달아 주세요

objectMgr

Programing/flash 2015.11.20 15:37 |

package objects.ObjectMgr
{
 
 import flash.geom.Point;
 import starling.display.Sprite;
 import starling.display.MovieClip;
 import starling.events.EnterFrameEvent;
 import starling.events.Event;
 import objects.*;

 import starling.display.Button;
 import starling.utils.HAlign;
 import starling.utils.VAlign;
 import starling.text.TextField;
 import com.greensock.TweenLite;
 import UI.BigInt;
 import starling.display.Image;
 import starling.utils.deg2rad;
 import starling.core.Starling;

 import screens.InGame.InGame;
 
 import flash.utils.getDefinitionByName;
 

 
 /**
  * ...
  * @author dfsdf
  */
 public class ObjectMgr  extends Sprite
 {
  private var m_type:int = 0;
  private var m_layerSprite:Sprite;
  private var m_frontlayerSprite:Sprite;
  private var m_layerIdx:int = 0;
  
  
  public var MAX_MON_CNT:int = 0;
  private var m_vecMon:Vector.<*> = new Vector.<*>;
  
  
  private var m_objectType:String;
  private var m_passedTime:Number = 0;
  
  
  public var m_updateState:Boolean = false;
  
  dropStar, stopStar;
  
  public function ObjectMgr(  layer:Sprite ,frontLayer:Sprite, layerIdx:int ,  typeName:String ,cnt:int  )
  {
   super();
   //m_type = type;
   m_layerSprite = layer;
   m_frontlayerSprite = frontLayer;
   m_layerIdx = layerIdx;
   
   m_objectType  = typeName;
   
   MAX_MON_CNT = cnt;
   
   this.addEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedStage);
   this.addEventListener(starling.events.Event.REMOVED_FROM_STAGE, onRemoveStage);

   this.addEventListener(EnterFrameEvent.ENTER_FRAME, update);
  
  }
  
  private function onAddedStage():void
  {
   this.removeEventListener(starling.events.Event.ADDED_TO_STAGE, onAddedStage);
   
   init();

  }
  
   
  private function onRemoveStage():void
  {
   this.removeEventListener(starling.events.Event.REMOVED_FROM_STAGE, onRemoveStage);

  }
  
  public function init ():void
  {
   var tempMon:Sprite;
   for ( var i:int = 0;  i < MAX_MON_CNT ; i++)
   {
    var classRef:Class = getDefinitionByName("objects."+m_objectType) as Class;
    tempMon = new classRef( m_layerSprite );
    tempMon.x = 0 + i* 40;
    
    tempMon.visible = false;//false;
    //if ( i%2 == 0)
    //{
    
    if ( m_layerIdx == 0)
    {
     //tempMon.y = 150;
     m_layerSprite.addChild( tempMon );
    }
    else if ( m_layerIdx == 1)
    {
     //tempMon.y = 180;
     m_frontlayerSprite.addChild( tempMon );
    }
     
    //}
    //else
    //{
    // tempMon.y = 180;
    // addChild( tempMon );
    // 
    //}
    m_vecMon.push( tempMon );

   }

  }
  
  private function update( e:EnterFrameEvent):void
  {
   if ( m_updateState == false)
    return ;
   
   m_passedTime += e.passedTime;
   
   if ( m_passedTime > 0.2 )
   {
    m_passedTime = 0;
    
    
    createMon( 1 );
   }
   
   for ( var i:int = 0;  i < MAX_MON_CNT ; i++)
   {
    if( m_vecMon[i].visible == true)
     m_vecMon[i].update();
   }
  }
  
  
  public function createMon( createCnt:int  = 1 ):void
  {
   var curCnt:int = 0;
   for ( var i:int = 0;  i < MAX_MON_CNT ; i++)
   {
    if ( m_vecMon[i].visible == false)
    {
     if ( createCnt >= curCnt )
     {
      if ( m_vecMon[i].create() == true)
      {
      
       curCnt += 1;
      }
      
     }
     else
     {
      break;
     }
    }
   }
  }
  
  public function initCreate( createCnt :int = 6 ):void
  {
   var curCnt:int = 0;
   
   
   for ( var i:int = 0;  i < MAX_MON_CNT ; i++)
   {
    if ( m_vecMon[i].visible == false)
    {
     if ( createCnt >= curCnt )
     {
      m_vecMon[i].initCreate();
      
      curCnt += 1;
      
     }
     else
     {
      break;
     }
    }
   }
  }//end func.
  
  
  public function allOffVisible( val:Boolean = false ):void
  {
   for ( var i:int = 0;  i < MAX_MON_CNT ; i++)
   {
    m_vecMon[i].visible = val;

   }
  }
  
  
 }

}

'Programing > flash' 카테고리의 다른 글

starling main frame  (0) 2015.11.20
starling moviebutton  (0) 2015.11.20
coineff  (0) 2015.11.20
baseEff  (0) 2015.11.20
objectMgr  (0) 2015.11.20
flash 용 app 인증 파일 만들기  (0) 2012.12.11
Posted by 패스맨

댓글을 달아 주세요