zoukankan      html  css  js  c++  java
  • 绘制刚体(二)

    与第一个绘制刚体例子一样的,在舞台上点击鼠标拖动,绘制刚体。舞台上有两个RadioButton,用来选择是画矩形的刚体还是圆形的刚体。

    下面是mouseUp事件监听处理函数:

        private function onUp(e:MouseEvent):void 
    		{
    			_bodyContainer.graphics.clear();
    			_isDown = false;
    			stage.removeEventListener(MouseEvent.MOUSE_MOVE, onMove);
    			stage.removeEventListener(MouseEvent.MOUSE_UP, onUp);
    			
    			var endx:int = stage.mouseX;
    			var endy:int = stage.mouseY;
    			
    			var int;
    			var height:int;
    			
    			var random:int = 1 + Math.floor(Math.random()*10);
    			if (_isDrawRect)
    			{
    				if (endx<_initx)
    				{
    					var tempx:int = _initx;
    					_initx = endx;
    					endx = tempx;
    				}
    				if (endy<_inity)
    				{
    					var tempy:int = _inity;
    					_inity = endy;
    					endy = tempy;
    				}
    				width = Math.abs(endx - _initx);
    				height = Math.abs(endy - _inity);
    				if (width == 0 || height == 0) return;
    				var myRect:Rect = new Rect(width, height, new Point(_initx + width / 2, _inity + height / 2), new Point(), new MyRect(), _bodyContainer);
    				(myRect.displayObject as MovieClip).gotoAndStop(random);
    				_actors.push(myRect);
    			}
    			else
    			{
    				width = Math.abs(endx - _initx);
    				height = Math.abs(endy - _inity);
    				if (width == 0 || height == 0) return;
    				var dist:Number = Math.sqrt(width * width + height * height);
    				trace(dist, width, height);
    				var myCircle:Ball = new Ball(dist, new Point(_initx, _inity), new Point(), new MyCircle(), _bodyContainer);
    				(myCircle.displayObject as MovieClip).gotoAndStop(random);
    				_actors.push(myCircle);
    			}
    		}
    

  • 相关阅读:
    OCP-1Z0-053-V12.02-515题
    OCP-1Z0-053-V12.02-605题
    OCP-1Z0-053-V12.02-648题
    OCP-1Z0-053-V12.02-669题
    OCP-1Z0-053-V12.02-83题
    OCP-1Z0-053-V12.02-215题
    OCP-1Z0-053-V12.02-514题
    OCP-1Z0-053-V12.02-666题
    OCP-1Z0-053-V12.02-602题
    Oracle DB执行闪回数据库
  • 原文地址:https://www.cnblogs.com/ywxgod/p/1713987.html
Copyright © 2011-2022 走看看