不要誤會,這隻是用來交流用的!脫衣服這個遊戲,用到了很多bitmapData,以及一些AS對于圖檔渲染的一些API,是以自己做了一個,把源代碼發上來,以供參考。
package
{
import flash.display.Bitmap;
import flash.display.BitmapData;
import flash.display.BlendMode;
import flash.display.Sprite;
import flash.display.StageAlign;
import flash.display.StageScaleMode;
import flash.events.MouseEvent;
import flash.geom.Matrix;
import flash.geom.Rectangle;
public class TuoYi extends Sprite
{
//背景素材
[Embed(source="res/girl.jpg")] var Pic:Class;
private var background:Bitmap = new Pic();
//遮擋資料
private var bmd:BitmapData = new BitmapData(stage.fullScreenWidth,stage.fullScreenHeight,
true,0);
//遮擋資料圖檔
private var bm:Bitmap = new Bitmap(bmd);
//看不見的畫闆
private var drawCanvas:Sprite = new Sprite();
public function TuoYi()
{
super();
// support autoOrients
stage.align = StageAlign.TOP_LEFT;
stage.scaleMode = StageScaleMode.NO_SCALE;
//設定背景
this.addChild(background);
background.width = stage.fullScreenWidth;
background.height = stage.fullScreenHeight;
this.mouseEnabled = false;
//畫出的看不見的畫闆的顔色病添加到圖形上,并設定BlendMode.LAYER
drawCanvas.graphics.beginFill(0xff0000);
drawCanvas.graphics.lineStyle(20,0xff0000);
drawCanvas.graphics.drawRect(0,0,stage.fullScreenWidth,stage.fullScreenHeight);
this.addChild(bm);
//将區域程式設計紅色
bmd.draw(drawCanvas,null,null,BlendMode.LAYER);
//添加各種監聽事件
stage.addEventListener(MouseEvent.MOUSE_DOWN,onMouseDown);
stage.addEventListener(MouseEvent.MOUSE_UP,onMouseUp);
//性能監視
stage.addChild(new Stats());
}
protected function onMouseUp(event:MouseEvent):void
{
stage.removeEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
}
protected function onMouseMove(event:MouseEvent):void
{
drawCanvas.graphics.lineTo(this.mouseX,this.mouseY);
bmd.draw(drawCanvas,null,null,BlendMode.ERASE);
}
protected function onMouseDown(event:MouseEvent):void
{
drawCanvas.graphics.clear();
drawCanvas.graphics.lineStyle(40,0);
drawCanvas.graphics.moveTo(this.mouseX,this.mouseY);
stage.addEventListener(MouseEvent.MOUSE_MOVE,onMouseMove);
}
}
}