var deger:String = "";
stage.addEventListener(Event.ENTER_FRAME,git);
function git(e:Event):void
{
if (deger=="yukari")
{
topmc.y -= 10;
}
if (deger=="asagi")
{
topmc.y += 10;
}
if (deger=="sol")
{
topmc.x -= 10;
}
if (deger=="sag")
{
topmc.x += 10;
}
if (topmc.hitTestObject(yemmc))
{
topmc.width += 10;
topmc.height += 10;
yemmc.x=Math.round(Math.random()*550);
yemmc.y=Math.round(Math.random()*400);
}
}
stage.addEventListener(KeyboardEvent.KEY_DOWN,yonbul);
function yonbul(e:KeyboardEvent):void
{
if (e.keyCode == Keyboard.UP)
{
deger = "yukari";
}
if (e.keyCode == Keyboard.DOWN)
{
deger = "asagi";
}
if (e.keyCode == Keyboard.LEFT)
{
deger = "sol";
}
if (e.keyCode == Keyboard.RIGHT)
{
deger = "sag";
}
}
var zamanlayici:Timer = new Timer(5000);
zamanlayici.addEventListener(TimerEvent.TIMER,yaz);
function yaz(e:TimerEvent):void
{
//trace("merhaba");
yemmc.x=Math.round(Math.random()*550);
yemmc.y=Math.round(Math.random()*400);
}
zamanlayici.start();
Hiç yorum yok :
Yorum Gönder