Please login or register.

Login with username, password and session length
Advanced search  

News:

This forum provides RSS feed. To query recent posts use this url. More...


Author Topic: Moving actor by Keyboard?  (Read 3036 times)

0 Members and 1 Guest are viewing this topic.

ZaHeR92

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Moving actor by Keyboard?
« on: April 27, 2009, 12:15:07 PM »

Hello friends...

I becomed a tiered from tring to do this...

I want to move my actor by keyboard and I did that ..

Code: [Select]
   if (Keyboard.KeyCode == VK_UP) {
      actor.GoTo(actor.X, actor.Y-50);
   } else if (Keyboard.KeyCode == VK_DOWN) {
      actor.GoTo(actor.X, actor.Y+50);
   } else if (Keyboard.KeyCode == VK_LEFT) {
      actor.GoTo(actor.X-50, actor.Y);
   } else if (Keyboard.KeyCode == VK_RIGHT) {
      actor.GoTo(actor.X+50, actor.Y);

and it works very well ..but I need the other 4 direction UpRight , UpLeft , DownRight and DownLeft...

now I can do that by the space for example:

Code: [Select]
   } else if (Keyboard.KeyCode == VK_SPACE){
      actor.GoTo(actor.X+50, actor.Y+50);

and it works very good
But I want to exchange the space(VK_SPACE) and but Down and Right bottons together on the keyboard..

I tried:

Code: [Select]
   } else if (Keyboard.KeyCode == VK_RIGHT + VK_DOWN){
      actor.GoTo(actor.X+50, actor.Y+50);

but it dos not work..

my question is:

How can I choose two keys on the keyboard must be cleacked together to do event?

Logged

mylesblasonato

  • Developer
  • Frequent poster
  • ****
  • Karma: 0
  • Offline Offline
  • Gender: Male
  • Posts: 265
  • "Give up is to fail as sacrifice is to succeed"
    • View Profile
    • Royal Wins
Re: Moving actor by Keyboard?
« Reply #1 on: April 27, 2009, 12:19:23 PM »

Hi there,
I'm not really sure how it works in WME but in other programming languages the code looks like this:

Code: [Select]
  } else if (Keyboard.KeyCode == VK_RIGHT && Keyboard.KeyCode == VK_DOWN){
      actor.GoTo(actor.X+50, actor.Y+50);

Give that a go and let us know.

Cheers ::beer
Myles Blasonato.
Logged
Lead Game Designer, Royal Wins.
@mylesblasonato
@royalwins
http://au.linkedin.com/pub/myles-blasonato/26/600/a38

ZaHeR92

  • Lurker
  • *
  • Karma: 0
  • Offline Offline
  • Posts: 13
    • View Profile
Re: Moving actor by Keyboard?
« Reply #2 on: April 27, 2009, 12:31:51 PM »

 :'( I try it but it dose not work...

thank you for tring,,,
Logged

Mnemonic

  • WME developer
  • Administrator
  • Addicted to WME forum
  • *
  • Karma: 41
  • Offline Offline
  • Gender: Male
  • Posts: 5683
    • View Profile
    • Dead:Code Site
Re: Moving actor by Keyboard?
« Reply #3 on: April 27, 2009, 12:44:14 PM »

Please take a look at this thread: http://forum.dead-code.org/index.php?topic=3526.msg21590#msg21590
And consider using the keyboard control code from 'Spank the hero' demo.
Logged
Yes, I do have a twitter account
Please don't send me technical questions in private messages, use the forum. ::wave
 

Page created in 0.116 seconds with 23 queries.