i'm trying to make a drag and drop game, i have done the background and the iteams to drop, but have no idea how to set where to drop them to.
my game is desinged thus ; you have to drag bats into a cave, trouble is the cave is the background image, i placed it in flash useing only code, can someone please help me understand how to set the cave as the target area for the bats and to get the bat to dissapear and add some points to the score. if anyone can help i would be very greatful.
my code so far is below:
var castle:castleBg = new castleBg();
addChild(castle);
castle.x=400;
castle.y=466;
addEventListener(Event.ENTER_FRAME,myFunction);
function myFunction(event:Event)
{
enterframelistener();
enterframelistener1();
}
function enterframelistener() // move left
{
if (stage.mouseX > 800)
{
const speed:int= -25;
castle.x += speed;
const CastleOFFSET:int= 5
}
}
function enterframelistener1() //move right
{
if (stage.mouseX < 250)
{
const speed:int= 25;
castle.x += speed;
const CastleOFFSET:int=-5
}
}
var bat:vBat = new vBat();
castle.addChild(bat);
bat.x=-250;
bat.y=-300;
bat.addEventListener(MouseEvent.MOUSE_DOWN, pickUp);
bat.addEventListener(MouseEvent.MOUSE_UP, dropIt);
function pickUp(event:MouseEvent):void {
event.target.startDrag(false);
//trace("Drag Started!");
}
function dropIt(event:MouseEvent):void {
event.target.stopDrag();
bat.visible = false;
//trace("Drag Stoped!");
}
bat.buttonMode = true;
var tMouth:mouth = new mouth(); // this is where the bat will hit and vanish
castle.addChild(tMouth);
tMouth.x= 200;
tMouth.y=350;
// if(this.hitTestObject(tMouth)) {
trace ("hit");
}
Mod edit - Please

New Topic/Question
Reply



MultiQuote





|