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 패스맨

댓글을 달아 주세요