[AS3]as3精确到点的碰撞测试源代码示例
[AS3]as3精确到点的碰撞测试源代码示例,as3碰撞,as3精确碰撞,碰撞
[AS3]as3精确到点的碰撞测试源代码示例
- package
- {
- import com.ui.Star;
- import flash.display.Bitmap;
- import flash.display.BitmapData;
- import flash.display.Sprite;
- import flash.display.StageAlign;
- import flash.display.StageScaleMode;
- import flash.events.MouseEvent;
- import flash.filters.GlowFilter;
- import flash.geom.Matrix;
- import flash.geom.Point;
- public class Main extends Sprite
- {
- private var bmpd1:BitmapData;
- private var bmp1:Bitmap;
- private var bmpd2:BitmapData;
- private var bmp2:Bitmap;
- public function Main():void
- {
- //cuplayer.com提示:初始化代码
- init();
- }
- private function init():void
- {
- stage.align = StageAlign.TOP_LEFT;
- stage.scaleMode = StageScaleMode.NO_SCALE;
- var star:Star = new Star(50);
- bmpd1 = new BitmapData(100,100,true,0);
- bmpd1.draw(star, new Matrix(1,0,0,1,50,50));
- bmp1 = new Bitmap(bmpd1);
- bmp1.x = 200;
- bmp1.y = 200;
- this.addChild(bmp1);
- bmpd2 = new BitmapData(100,100,true,0);
- bmpd2.draw(star, new Matrix(1,0,0,1,50,50));
- bmp2 = new Bitmap(bmpd2);
- this.addChild(bmp2);
- stage.addEventListener(MouseEvent.MOUSE_MOVE, onMouseMoving);
- }
- private function onMouseMoving(event:MouseEvent):void
- {
- bmp2.x = mouseX - 50;
- bmp2.y = mouseY - 50;
- if(bmpd1.hitTest(new Point(bmp1.x, bmp1.y), 255, bmpd2, new Point(bmp2.x, bmp2.y), 255))
- {
- bmp1.filters = [new GlowFilter()];
- bmp2.filters = [new GlowFilter()];
- }
- else
- {
- bmp1.filters = [];
- bmp2.filters = [];
- }
- }
- }
- }
热门文章推荐
- [HLS]做自己的m3u8点播系统使用HTTP Live Streaming(HLS技术)
- [FMS]FMS流媒体服务器配置与使用相关的介绍
- [AS3]什么是M3U8,与HTML5的区别是什么
- AS2.0 让flash自适应全屏,并且不自动缩放
- [AS3]as3.0的sound类常用技巧整理
- [AS3]as3与ByteArray详解、ByteArray介绍、ByteArray用法
- 关于RTMP,RTMPT,RTMPS,RTMPE,RTMPTE协议的介绍
- [JS]分享浏览器弹出窗口不被拦截JS示例
请稍候...