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

댓글을 달아 주세요