Jump to content
×
×
  • Create New...

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

Lorem Ipsum is simply dummy text

Lorem Ipsum is simply dummy text of the printing and typesetting industry. Lorem Ipsum has been the industry's standard dummy text ever since the 1500s

Test Test

  • Bu Alana Reklam Verebilirsiniz
    Bu Alana Reklam Verebilirsiniz

Klavye İle Çapraz Hareket Etme Kodları | Flash ActionScript 3.0

Rate this topic


programYaz

Recommended Posts

Klavye İle Çapraz Hareket Etme Kodları | Flash ActionScript 3.0
  • Members

Daha önceki derslerimizde actionscript 3.0 kullanarak sahnedeki bir nesneyi aşağı,yukarı,sağa ve sola olmak üzere dört yöne hareket ettirdik. O uygulamamızda ara yönlere hareket yoktu. Şimdi ise dört ana yönle beraber ara yönlere de hareket ettireceğiz. Ayrıca arabamız hareket ettiği yöne dönecek.

Bunun için aşağıdaki ufak açıklamayı dikkate almanızı tavsiye ederim. İlk önce resmi verelim ve açıklamasını yapalım.

 

arayon.png

 

Kırmızı okla gösterilen temsili araba resmi. Etrafındaki sayılar ise nesnenin nesneyi hangi yöne hareket ettireceksek o açıyı göstermektedir. Nesnelerini döndüreceğiniz zaman bunu da dikkate alırsanız daha kolay olacaktır.

Şimdi uygulamamıza geçelim.
Bir flash as3 uygulaması oluşturun ve hareket ettireceğiniz nesneyi çizin.
Çizdiğiniz nesneyi F8 tuşuna basın ve film klibine çevirin. Burada XY merkezi olarak (KAYIT kısmı) orta noktayı belirlemeyi unutmayın.
Nesnenin <Örnek Adı>‘nı araba olarak belirledim. Sizde kodları nesnenize göre düzenleyin.
Sahnede boş bir alana tıklayın ve F9 tuşuna basarak aşağıdaki kodları yazın.

 

araba.addEventListener(Event.ENTER_FRAME, hareket);
stage.addEventListener(KeyboardEvent.KEY_DOWN, tusabasildi);
stage.addEventListener(KeyboardEvent.KEY_UP, basmaisibitti);
var keys:Array = [];
function hareket(e:Event):void
{
    if (keys[Keyboard.UP] && keys[Keyboard.RIGHT])
    {
        araba.y -=  3;
		araba.x +=  3;
		araba.rotation=315;
    }
	else if (keys[Keyboard.UP] && keys[Keyboard.LEFT])
    {
        araba.y -=  3;
		araba.x -=  3;
		araba.rotation=225;
    }
	else if (keys[Keyboard.DOWN] && keys[Keyboard.LEFT])
    {
        araba.y +=  3;
		araba.x -=  3;
		araba.rotation=135;
    }
	else if (keys[Keyboard.DOWN] && keys[Keyboard.RIGHT])
    {
        araba.y +=  3;
		araba.x +=  3;
		araba.rotation=45;
    }
 
	else if (keys[Keyboard.RIGHT])
    {
        araba.x +=  3;
		araba.rotation=0;
    }
    else if (keys[Keyboard.LEFT])
    {
        araba.x -=  3;
		araba.rotation=180;
    }
    else if (keys[Keyboard.UP])
    {
        araba.y -=  3;
		araba.rotation=270;
    }
    else if (keys[Keyboard.DOWN])
    {
        araba.y +=  3;
		araba.rotation=90;
    }
}
function tusabasildi(e:KeyboardEvent):void
{
    keys[e.keyCode] = true;
}
function basmaisibitti(e:KeyboardEvent):void
{
    keys[e.keyCode] = false;
}

 

Ada LoveLace

Link to comment
https://weblep.com/topic/194-klavye-i%CC%87le-%C3%A7apraz-hareket-etme-kodlar%C4%B1-flash-actionscript-30/
Share on other sites


Konu Altı Reklam 1
Konu Altı Reklam 2
  • Replies 0
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

Posted Images

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...