Friday, March 27, 2015

Knotwood - Character Movement

I made a white square which shall henceforth be called a "character".  Someday, this character if ours may look like more than a white square, but only if we feed it and take care of it and make sure it knows it is loved.

Anyway, it's just another bitmap.

Next I had a bit of fun remembering how to make the character move.  I've made the simplistic version first, where just holding an arrow key down or the WASD keys sends the character is the right direction on the screen that you want.  Unfortunately figuring out the correct placement of the event listener took some time.

First I made a Player class with a Bitmap in it, and put the event listener in there.  That didn't take, so I put it in Main.  That didn't work, so I attached it to the Player object through main.  That didn't work, so I attached it to the stage.  That didn't work, so I changed the Player class so it extends the Bitmap class, and added it inside there.  That didn't work, so I then added it to Main again.  That didn't work, so I attached it to the Player class again through Main.  That didn't work so I attached it to the Stage again through Main.  Ah! There we are.

Only the last possible combination of class types and attachments, of course.

But it works.  And that is a lovely thing.

2 comments:

  1. Hey just stumbled on your blog searching for heroquest stuff. That's good enough for a follow. ;)

    ReplyDelete
    Replies
    1. Thanks! I should get back into HeroQuest mods; seems to be my most popular feature!

      Delete