dcsimg
A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: total AS newbie, question!

  1. #1
    Member
    Join Date
    Apr 2001
    Posts
    55

    total AS newbie, question!

    Hi all,

    I've just recently decided to tackle Actionscript, as I want to start developing some games.

    Anyhoo, a question regarding binding the mouse to a movieclip (character sprite). My character will have 8 different positions (N, NE, E, SE, S, SW, W, NW) and would need to face each direction according to mouse drag.

    My sprite will be able to walk forward, backward, left and right (using the W, A, S, D keys) but will "point" according to where he's facing, according to where you'd drag the mouse.

    Just off the top of my head, my guess is that I'd need to set the mouse cursor centerpoint to be the center of my character sprite, correct? What would be a wise way to approach the rest?

    Sorry, I have no code! I'm just learning all this stuff right now. Thanks in advance.

  2. #2
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273
    ...drag? It would be much eaiser to just have the character *face* wherever the mouse is. Dragging would be silly and near impossible.

    You'd need to get the X and Y positions of the mouse and then compare them to the X and Y positions of the character, then do several dozen IF statements to determine what sprite to show (like if mouse._y == character._y && mouse._x > character._x) { show crap } and you'd need to do a lot of thinking about it.

    Basically this is a far too huge project for your first time actionscripting.

  3. #3
    Member
    Join Date
    Apr 2001
    Posts
    55
    thanks for the response.

    Yeah, I know it's a big daddy here...I guess I'm more interested in how the logic of it all would work, you know? And what you describe makes total sense. I got the idea when I was looking at one of the tutorials that showed a gun turret rotating when you moved the mouse.

    When you say I'd need to "get the X and Y positions of the mouse and compare them, etc.." do you mean by literally getting them or by having a script (or whatever you'd call it) try to detect them?

  4. #4
    Senior Member
    Join Date
    Apr 2003
    Location
    MA
    Posts
    273
    The mouse X and Y are global variables that can be used anywhere in Actionscript, I think. It's just _root.xmouse and _root.ymouse

  5. #5
    Member
    Join Date
    Apr 2001
    Posts
    55
    Gotcha.

    BTW, would you have any suggestions for a good actionscript book for reference? I just retain information more from books than I do from online docs. Thanks in advance.

  6. #6
    Senile member! :)
    Join Date
    Dec 2001
    Location
    Saunaswamp (transl)
    Posts
    2,296
    This is the book you should get:
    http://www.amazon.com/gp/product/059...lance&n=283155

    If you feel upto learning AS 2.0 get this book too(You need to know some actionscript before you buy this book since it only deals with the OOP aproach used by AS 2.0):
    http://www.amazon.com/gp/product/059...lance&n=283155

    /Mirandir

  7. #7
    Member
    Join Date
    Apr 2001
    Posts
    55
    Excellent! I'll definitely look those up. This is pretty exciting....I understand the logic of how things need to work, its just the syntax I'm not up on. I'm confident I can get the hang of this.

    I'll be posting my progress pretty soon, so stay tuned!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  




Click Here to Expand Forum to Full Width

HTML5 Development Center