zoukankan      html  css  js  c++  java
  • 游戏中的镜头

    游戏中的镜头。锁定对象,根据计算坐标,修改父容器坐标,让物品处于最中点。

    package
    {
    	import flash.display.Sprite;
    	import flash.display.Stage;
    	import flash.events.Event;
    	import flash.filters.GlowFilter;
    	import flash.geom.Point;
    
    	/**
    	 *  @author:Gaara
    	 *  2012-3-16
    	 *
    	 **/
    	public class Camer extends Sprite
    	{
    		private var myStage:Stage;
    		private var target:Sprite;
    		
    		public function Camer(stage:Stage)
    		{
    			addChild(ResConfig.myLpBmp);
    			this.myStage = stage;
    			this.addEventListener(Event.ENTER_FRAME,onEnterFrame);
    		}
    		
    		/**
    		 *  功能:
    		 *  参数:
    		 **/
    		public function lockAt(target:Sprite):void
    		{
    			if(this.target != null){
    				this.target.filters = [];
    			}
    			this.target = target;
    			target.filters = [new GlowFilter(0x00FF00)];
    		}
    		
    		protected function onEnterFrame(event:Event):void
    		{
    			if(this.target != null){
    				var spriteCP:Point = globalToLocal(new Point(stage.stageWidth/2,stage.stageHeight/2));
    				
    				var decX:Number = target.x -  spriteCP.x;
    				var decY:Number = target.y - spriteCP.y ;
    				x -= decX;
    				y -= decY;
    			}
    		}
    	}
    }
    
  • 相关阅读:
    HashMap底层实现原理(JDK1.8)源码分析
    JVM总结
    初识Nosql
    线程池总结
    Linux中常用操作命令
    JAVA—集合框架
    TeKtronix TDS210数字示波器使用简介
    硬盘的物理结构
    Unicode 与 UTF
    I2C串行总线
  • 原文地址:https://www.cnblogs.com/riaol/p/2400451.html
Copyright © 2011-2022 走看看