你好我想製作一個歐洲閃光地圖,當你將鼠標懸停在每個國家或者出於某個國家之外時,就會發生一些事情,比如改變國家的顏色。製作閃光國家地圖
看到該圖片
如果我翻身挪威,然後瑞典,瑞典將不會被設置爲藍色,因爲挪威的邊框是瑞典的頂部,所以我必須去低一點翻身瑞典與挪威沒有互動。
有沒有更好的方法來實現相同的功能?就像使用位圖像素一樣。
我有一個sprite表中所有的png格式的錢幣。我嵌入這個精靈表,並創建Sprite AS3類,它使用copyPixels()從精靈表複製到innet變量BitmapData。
下面是使用copyPixels我的課
public class Country extends Sprite
{
private var newBitmap:Bitmap;
private var tintColor:Color = new Color();
public function Country(bitmapData:BitmapData)
{
newBitmap = new Bitmap(bitmapData);
tintColor.setTint (0x0000ff, 0.6);
this.useHandCursor = true;
this.buttonMode = true;
addEventListener(Event.ADDED_TO_STAGE, init);
}
private function init(e:Event):void
{
addChild(newBitmap);
addEventListener(MouseEvent.MOUSE_OVER, onMouseOver);
addEventListener(MouseEvent.MOUSE_OUT, onMouseOut);
}
private function onMouseOver(e:MouseEvent = null):void
{
newBitmap.transform.colorTransform = tintColor;
}
private function onMouseOut(e:MouseEvent = null):void
{
newBitmap.transform.colorTransform = new ColorTransform();
}
}
位圖數據被創建在運行時()這樣的
var countiresArray:Array = Resources.allCointriesJSON["frames"];
var newX:Number = countiresArray[i]["frame"]["x"];
var newY:Number = countiresArray[i]["frame"]["y"];
var newW:Number = countiresArray[i]["frame"]["w"];
var newH:Number = countiresArray[i]["frame"]["h"];
bitmapData .copyPixels(Resources.allCountries.bitmapData, new Rectangle(newX, newY, newW, newH), new Point(0, 0));
其中下一頁末,NewY,東西方婦女網絡和newH是從創建導出JSON文件中取出當使用TexturePacker
您的國家是由單獨的透明位圖組成嗎? –
是的,每個國家都是PNG文件,但我使用TexturePacker將它們打包在一個PNG – Vlad