所以我创造了一个游戏,你必须找到3个项目,然后点击门并赢得游戏,所以这里有一些东西填满了我的游戏。当你打开游戏并运行它时,你会在左侧看到2个灰色的岩石,当我点击拖动它们时它们会坚持光标,但是当我点击板条箱拖动它们时它们不粘,我怎么能让它像板条箱一样?
stop();
inventorycrowbar_mc.alpha = 0;
inventorypotion_mc.alpha = 0;
inventoryflashlight_mc.alpha = 0;
crowbar_mc.addEventListener(MouseEvent.MOUSE_DOWN, objectFound);
potion_mc.addEventListener(MouseEvent.MOUSE_DOWN, objectFound);
flashlight_mc.addEventListener(MouseEvent.MOUSE_DOWN, objectFound);
var founditems:Number=0;
function pickupObject(event:MouseEvent):void {
event.target.startDrag(true);
}
function dropObject(event:MouseEvent):void {
event.target.stopDrag();
}
crate1_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
crate1_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
crate1_mc.buttonMode=true;
crate2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
crate2_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
crate2_mc.buttonMode=true;
crate3_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
crate3_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
crate3_mc.buttonMode=true;
crate4_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
crate4_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
crate4_mc.buttonMode=true;
boulder1_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
boulder1_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
boulder1_mc.buttonMode=true;
boulder2_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
boulder2_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
boulder2_mc.buttonMode=true;
drum3_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
drum3_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
drum3_mc.buttonMode=true;
grass_mc.addEventListener(MouseEvent.MOUSE_DOWN, pickupObject);
grass_mc.addEventListener(MouseEvent.MOUSE_UP, dropObject);
grass_mc.buttonMode=true;
function escapeRoom(event:MouseEvent):void {
gotoAndStop(2);
}
function objectFound(event:MouseEvent):void {
var inventoryName:String = "inventory" + event.target.name;
var inventoryItem:DisplayObject = getChildByName(inventoryName);
event.target.alpha = inventoryItem.alpha = 100;
founditems ++;
event.target.alpha = 0;
if(founditems == 3){
door_btn.addEventListener(MouseEvent.MOUSE_DOWN, escapeRoom);
}
}
我已将我的flash投影附加到下面的链接。
https://drive.google.com/file/d/0B-EnwwKnY8EqbDNSX0JyV01NeTA/view?usp=sharing
游戏还没有结束,因为我需要重新设计游戏主题,所以有几个搞砸了,只是忽略它们。找到的3个项目是手电筒,药水和红色扳手,然后点击门赢。