'2015/11'에 해당되는 글 6건

  1. 2015.11.20 texturepacker license post
  2. 2015.11.20 starling main frame
  3. 2015.11.20 starling moviebutton
  4. 2015.11.20 coineff
  5. 2015.11.20 baseEff
  6. 2015.11.20 objectMgr

TP:78DD247B

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

texturepacker license post  (0) 2015.11.20
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
Posted by 패스맨

댓글을 달아 주세요

package
{

 import flash.display.Sprite;
 import flash.geom.Rectangle;
 import net.hires.debug.Stats;
 import starling.events.Event;
 import starling.text.TextField;
 
 
 import flash.events.Event;
 
 import screens.InGame.*;
 //import screens.Logo;
 import starling.core.Starling;
 
 import flash.display.StageAlign;
 import flash.display.StageScaleMode;
 
 import flash.desktop.NativeApplication;

 import flash.net.URLLoader;
 
 import flash.net.URLRequest;
 import flash.net.URLVariables;
 
 import flash.media.StageWebView;
 import flash.events.ErrorEvent;
 import flash.events.LocationChangeEvent;
 import flash.events.Event;
 
 /*
 CONFIG::MOBILE
 {
 import com.sticksports.nativeExtensions.SilentSwitch;
 }
 */
 
 /*
 CONFIG::ANDROID
 {
  import com.milkmangames.nativeextensions.*;
  import com.milkmangames.nativeextensions.events.GoogleGamesEvent;
  import com.milkmangames.nativeextensions.events.*;
  
  import com.milkmangames.nativeextensions.GoogleGames;
 }
 */
 
 import flash.display.StageDisplayState;
 

 //import pl.mllr.extensions.contactEditor.ContactEditor;
 import flash.geom.Point;
 import starling.utils.RectangleUtil;
 import starling.utils.ScaleMode;
 import flash.system.Capabilities;
 import Game;
 import   flash.media.AudioPlaybackMode;
 import   flash.media.SoundMixer;

 
 //[SWF(frameRate="60", width="1024", height="748", backgroundColor="0x333333")]e87474
 [SWF(frameRate="60",  width="320", height="568" ,backgroundColor="0xffffff")] //0xffffff //0x2a2a2d
 public class Main extends Sprite
 {
  
  //private var stats:Stats;
  
  //private var myStarling:Starling;
  
  //1136
  //640
  
  //320;
  // 568;
  
  private const SCREEN_WIDTH:int = 320;
  private const SCREEN_HEIGHT:int = 568;
  
  private function onResize(event:starling.events.Event, size:Point):void
  {
   RectangleUtil.fit(
    new Rectangle(0, 0, stage.stageWidth, stage.stageHeight),
    new Rectangle(0, 0, size.x, size.y),
    ScaleMode.SHOW_ALL, false,
    Starling.current.viewPort
   );
  }

  public  function Main()
  {
   //super();
  
  
   
   var isMobile:Boolean = false;
   CONFIG::MOBILE
   {
    isMobile = true;
   }
   
   
   
   if ( isMobile == false)
   {
    /*
    stats = new Stats();
    stats.y = 200;
    stats.scaleX = 1;
    stats.scaleY = 1;
    */
    //this.addChild(stats);
   }
   
   
  
  
   //stage.scaleMode = StageScaleMode.NO_SCALE;
   //stage.align = StageAlign.TOP_LEFT;
   
   /*
   CONFIG::MOBILE
   {
   SilentSwitch.apply();//진동모드 일때 무음
   }
   */
 
   var screenWidth:int = stage.fullScreenWidth;
   var screenHeight:int = stage.fullScreenHeight;
   
   Assets.fullScreenWidth = screenWidth;
   Assets.fullScreenHeight = screenHeight ;
   
   var viewport:Rectangle =  //new Rectangle( 0, 0, stage.stageWidth, stage.stageHeight);
   new Rectangle( 0, 0, screenWidth, screenHeight);
   
   //멀티터치 사용여부
   Starling.multitouchEnabled = true;
   Starling.handleLostContext = true; // deactivate on
  
   stage.quality = "high";
   
   //stage.displayState = StageDisplayState.FULL_SCREEN_INTERACTIVE;
    
   Assets.myStarling = new Starling( Game , stage, viewport);
   stage.quality = "high";
   //stage.frameRate = 60;
   
  
   
   if ( screenHeight == 1136)
    Assets.isIPHONE5 = true;
   else
   {
    Assets.isIPHONE5 = true;
    //Assets.isIPHONE5 = false;
   }
   
 
   //Assets.isIPHONE5 = true;
   
   if ( Assets.isIPHONE5 == true)
   {
    Assets.myStarling.stage.stageWidth = SCREEN_WIDTH;
    Assets.myStarling.stage.stageHeight = SCREEN_HEIGHT; 
    
   }
   else
   {
    Assets.myStarling.stage.stageWidth = SCREEN_WIDTH;
    Assets.myStarling.stage.stageHeight = SCREEN_HEIGHT;
   }
   
   Assets.stageWCenter = SCREEN_WIDTH / 2;//stage.stageWidth / 2;
   Assets.stageHCenter = SCREEN_HEIGHT / 2;// stage.stageHeight / 2;
   Assets.itemSpwaningArea =  SCREEN_WIDTH + SCREEN_WIDTH / 3;//stage.stageWidth + stage.stageWidth / 3;
   Assets.stageWidth  = SCREEN_WIDTH;//stage.stageWidth;
   Assets.stageHeight = SCREEN_HEIGHT;// stage.stageHeight;
   
   
   //Assets.flashStage = stage;

   
   Assets.myStarling.antiAliasing = 0;
   //Assets.myStarling.simulateMultitouch = true;
   Assets.myStarling.start();
   //Assets.myStarling.simulateMultitouch = true;
   
   SoundMixer.audioPlaybackMode  =  AudioPlaybackMode.AMBIENT;
 
   stage.quality = "high";

  } 

 }
}

 

 

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

texturepacker license post  (0) 2015.11.20
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
Posted by 패스맨

댓글을 달아 주세요

// =================================================================================================
//
// Starling Framework
// Copyright 2011 Gamua OG. All Rights Reserved.
//
// This program is free software. You can redistribute and/or modify it
// in accordance with the terms of the accompanying license agreement.
//
// =================================================================================================

package starling.display
{
    import flash.geom.Rectangle;
    import flash.ui.Mouse;
    import flash.ui.MouseCursor;
 import starling.core.Starling;
   
    import starling.events.Event;
    import starling.events.Touch;
    import starling.events.TouchEvent;
    import starling.events.TouchPhase;
    import starling.text.TextField;
    import starling.textures.Texture;
    import starling.utils.HAlign;
    import starling.utils.VAlign;
 

    /** Dispatched when the user triggers the button. Bubbles. */
    [Event(name="triggered", type="starling.events.Event")]
   
    /** A simple button composed of an image and, optionally, text.
     * 
     *  <p>You can pass a texture for up- and downstate of the button. If you do not provide a down
     *  state, the button is simply scaled a little when it is touched.
     *  In addition, you can overlay a text on the button. To customize the text, almost the
     *  same options as those of text fields are provided. In addition, you can move the text to a
     *  certain position with the help of the <code>textBounds</code> property.</p>
     * 
     *  <p>To react on touches on a button, there is special <code>triggered</code>-event type. Use
     *  this event instead of normal touch events - that way, users can cancel button activation
     *  by moving the mouse/finger away from the button before releasing.</p>
     */
    public class MovieButton extends DisplayObjectContainer
    {
        private static const MAX_DRAG_DIST:Number = 50;
       
        private var mUpState:Vector.<Texture>;
        private var mDownState:Vector.<Texture>;
       
        private var mContents:Sprite;
        private var mBackground:MovieClip;
  
        private var mTextField:TextField;
        private var mTextBounds:Rectangle;
       
        private var mScaleWhenDown:Number;
        private var mAlphaWhenDisabled:Number;
        private var mEnabled:Boolean;
        private var mIsDown:Boolean;
        private var mUseHandCursor:Boolean;
       
        /** Creates a button with textures for up- and down-state or text. */
        public function MovieButton(upState:Vector.<Texture>, text:String="", downState:Vector.<Texture>=null)
        {
            if (upState == null) throw new ArgumentError("Texture cannot be null");
           
            mUpState = upState;
            mDownState = downState ? downState : upState;
            mBackground = new MovieClip(upState, 3);
   //Assets.setCenterMC(mBackground);
   Starling.juggler.add( mBackground);
            mScaleWhenDown = downState ? 1.0 : 0.9;
            mAlphaWhenDisabled = 0.5;
            mEnabled = true;
            mIsDown = false;
            mUseHandCursor = true;
            mTextBounds = new Rectangle(0, 0, upState[0].width, upState[0].height);           
           
            mContents = new Sprite();
            mContents.addChild(mBackground);
            addChild(mContents);
            addEventListener(TouchEvent.TOUCH, onTouch);
           
            this.text = text;
        }
  
  public function stopAnim():void
  {
   mBackground.stop();
  }
  
  public function playAnim():void
  {
   mBackground.play();
  }
  
  public function setFrame( f:int ):void
  {
   mBackground.currentFrame = f;
  }
  
  public function getCurFrame():int
  {
   return mBackground.currentFrame;
  }
       
        private function resetContents():void
        {
            mIsDown = false;
           // mBackground.texture = mUpState[0];
            mContents.x = mContents.y = 0;
            mContents.scaleX = mContents.scaleY = 1.0;
        }
       
        private function createTextField():void
        {
            if (mTextField == null)
            {
                mTextField = new TextField(mTextBounds.width, mTextBounds.height, "");
                mTextField.vAlign = VAlign.CENTER;
                mTextField.hAlign = HAlign.CENTER;
                mTextField.touchable = false;
                mTextField.autoScale = true;
                mTextField.batchable = true;
            }
           
            mTextField.width  = mTextBounds.width;
            mTextField.height = mTextBounds.height;
            mTextField.x = mTextBounds.x;
            mTextField.y = mTextBounds.y;
        }
       
        private function onTouch(event:TouchEvent):void
        {
            Mouse.cursor = (mUseHandCursor && mEnabled && event.interactsWith(this)) ?
                MouseCursor.BUTTON : MouseCursor.AUTO;
           
            var touch:Touch = event.getTouch(this);
            if (!mEnabled || touch == null) return;
           
            if (touch.phase == TouchPhase.BEGAN && !mIsDown)
            {
                mBackground.texture = mDownState[0];
                mContents.scaleX = mContents.scaleY = mScaleWhenDown;
                mContents.x = (1.0 - mScaleWhenDown) / 2.0 * mBackground.width;
                mContents.y = (1.0 - mScaleWhenDown) / 2.0 * mBackground.height;
                mIsDown = true;
            }
            else if (touch.phase == TouchPhase.MOVED && mIsDown)
            {
                // reset button when user dragged too far away after pushing
                var buttonRect:Rectangle = getBounds(stage);
                if (touch.globalX < buttonRect.x - MAX_DRAG_DIST ||
                    touch.globalY < buttonRect.y - MAX_DRAG_DIST ||
                    touch.globalX > buttonRect.x + buttonRect.width + MAX_DRAG_DIST ||
                    touch.globalY > buttonRect.y + buttonRect.height + MAX_DRAG_DIST)
                {
                    resetContents();
                }
            }
            else if (touch.phase == TouchPhase.ENDED && mIsDown)
            {
                resetContents();
                dispatchEventWith(Event.TRIGGERED, true);
            }
        }
       
        /** The scale factor of the button on touch. Per default, a button with a down state
          * texture won't scale. */
        public function get scaleWhenDown():Number { return mScaleWhenDown; }
        public function set scaleWhenDown(value:Number):void { mScaleWhenDown = value; }
       
        /** The alpha value of the button when it is disabled. @default 0.5 */
        public function get alphaWhenDisabled():Number { return mAlphaWhenDisabled; }
        public function set alphaWhenDisabled(value:Number):void { mAlphaWhenDisabled = value; }
       
        /** Indicates if the button can be triggered. */
        public function get enabled():Boolean { return mEnabled; }
        public function set enabled(value:Boolean):void
        {
            if (mEnabled != value)
            {
                mEnabled = value;
                mContents.alpha = value ? 1.0 : mAlphaWhenDisabled;
                resetContents();
            }
        }
       
        /** The text that is displayed on the button. */
        public function get text():String { return mTextField ? mTextField.text : ""; }
        public function set text(value:String):void
        {
            if (value.length == 0)
            {
                if (mTextField)
                {
                    mTextField.text = value;
                    mTextField.removeFromParent();
                }
            }
            else
            {
                createTextField();
                mTextField.text = value;
               
                if (mTextField.parent == null)
                    mContents.addChild(mTextField);
            }
        }
       
        /** The name of the font displayed on the button. May be a system font or a registered
          * bitmap font. */
        public function get fontName():String { return mTextField ? mTextField.fontName : "Verdana"; }
        public function set fontName(value:String):void
        {
            createTextField();
            mTextField.fontName = value;
        }
       
        /** The size of the font. */
        public function get fontSize():Number { return mTextField ? mTextField.fontSize : 12; }
        public function set fontSize(value:Number):void
        {
            createTextField();
            mTextField.fontSize = value;
        }
       
        /** The color of the font. */
        public function get fontColor():uint { return mTextField ? mTextField.color : 0x0; }
        public function set fontColor(value:uint):void
        {
            createTextField();
            mTextField.color = value;
        }
       
        /** Indicates if the font should be bold. */
        public function get fontBold():Boolean { return mTextField ? mTextField.bold : false; }
        public function set fontBold(value:Boolean):void
        {
            createTextField();
            mTextField.bold = value;
        }
       
        /** The texture that is displayed when the button is not being touched. */
        public function get upState():Texture { return mUpState[0]; }
        public function set upState(value:Texture):void
        {
            if (mUpState[0] != value)
            {
                mUpState[0] = value;
                if (!mIsDown) mBackground.texture = value;
            }
        }
       
        /** The texture that is displayed while the button is touched. */
        public function get downState():Texture { return mDownState[0]; }
        public function set downState(value:Texture):void
        {
            if (mDownState[0] != value)
            {
                mDownState[0] = value;
                if (mIsDown) mBackground.texture = value;
            }
        }
       
        /** The vertical alignment of the text on the button. */
        public function get textVAlign():String { return mTextField.vAlign; }
        public function set textVAlign(value:String):void
        {
            createTextField();
            mTextField.vAlign = value;
        }
       
        /** The horizontal alignment of the text on the button. */
        public function get textHAlign():String { return mTextField.hAlign; }
        public function set textHAlign(value:String):void
        {
            createTextField();
            mTextField.hAlign = value;
        }
       
        /** The bounds of the textfield on the button. Allows moving the text to a custom position. */
        public function get textBounds():Rectangle { return mTextBounds.clone(); }
        public function set textBounds(value:Rectangle):void
        {
            mTextBounds = value.clone();
            createTextField();
        }
       
        /** Indicates if the mouse cursor should transform into a hand while it's over the button.
         *  @default true */
        public override function get useHandCursor():Boolean { return mUseHandCursor; }
        public override function set useHandCursor(value:Boolean):void { mUseHandCursor = value; }
    }
}

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

texturepacker license post  (0) 2015.11.20
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
Posted by 패스맨

댓글을 달아 주세요

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

댓글을 달아 주세요