A Flash Developer Resource Site

Results 1 to 12 of 12

Thread: [help] Move character to mouse click.

  1. #1
    Junior Member
    Join Date
    Aug 2005
    Posts
    3

    [help] Move character to mouse click.

    I have just started makinig a game on flash, and i've got the hang of it (mostly) but i am struggling fin trying to make the character i made move to the mouse when clicked. I think i might have to do an array or something. I also want the character to change i'ts image when it moves(from down to up when clicked ubove etc.). if you can i would like your help.
    thanks

  2. #2
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    Hey there, welcome to flashKit .

    You problem can be done in a number of ways depending on what you want to do and how your game is made (tile based or art based)

    You can do any of the following..
    Angle movement - The character moves straight in the direction of the mouse when clicked.

    X and Y movement - the character moves to the mouses _x position and then to the mouses _y position (make colision detection slightly easyer if the game is tile based.

    Pathfinding - if the game is tile based (can be done in art based, but its far easyer with tiles) and you want the character to avoid walls and other unwalkable things then you need pathfinding. You really shouldnt try this though untill you are better at action script.

    Let us know what you want to do and how you game is made (art or tile?) and we can help further.

    Ali

  3. #3
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    Delete this please

  4. #4
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    The topic, or your post? If it's your post, just click 'edit' and choose 'delete'. If it's the topic, then why?
    http://www.birchlabs.co.uk/
    You know you want to.

  5. #5
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    yea i was talking about my post, wheres delete? never knew it existed.

    Ali

  6. #6
    AquaCorpse saves the day again
    Join Date
    Jun 2005
    Posts
    40
    click on edit and it's the first selection you can do, it has two bullets; delete and do not delete. check the delete and then hit the actual delete found under this message.
    aqua corpse he's a really cool guy...

  7. #7
    hmm Pugger's Avatar
    Join Date
    Sep 2003
    Location
    Perth, Australia
    Posts
    616
    There is an example of this sort of movement that came as a sample file with Flash MX (not sure about 2004). You click parts of the screen to make a lady bug go to that point. It would be useful to see, and is fairly simple.

    EDIT: Wanted to see if could see the delete post option - but can not see it. Am I blind?
    Last edited by Pugger; 08-28-2005 at 11:19 PM. Reason: Wanted to find delete

  8. #8
    Junior Member
    Join Date
    Aug 2005
    Posts
    3
    Thanks ali
    what do you mean by tile based and art based? i think mine is tile based, but im not sure about it.
    And i would like angle movement and pathfinding. If it is to hard for me i will try and find something else.
    thanks

  9. #9
    Senior Member tonypa's Avatar
    Join Date
    Jul 2001
    Location
    Estonia
    Posts
    8,227
    Quote Originally Posted by aquaCorpse
    click on edit and it's the first selection you can do, it has two bullets; delete and do not delete. check the delete and then hit the actual delete found under this message.
    Well, I think they have removed delete option in the upgrade so we are stuck with editing now.

  10. #10
    Insignificant Member Joshman_123's Avatar
    Join Date
    Nov 2004
    Posts
    395
    Here's an old code for point 'n click characters:

    onClipEvent (load) {
    rad = 0.0174532925199433;
    speed = 5;
    moving = false;
    }
    onClipEvent (mouseDown) {
    moving = true;
    m = {x:_parent._xmouse, y:_parent._ymouse};
    }
    onClipEvent (enterFrame) {
    if (moving) {
    mcx = _x-m.x;
    mcy = _y-m.y;
    _rotation = -Math.atan2(mcx, mcy)/rad;
    mr = _rotation*rad;
    if (Math.sqrt((mcx*mcx)+((mcy)*(mcy)))>speed) {
    _y -= speed*Math.cos(mr);
    _x -= -(speed*Math.sin(mr));
    } else {
    _x = m.x;
    _y = m.y;
    moving = false;
    }
    }
    }
    I have like, a gazillion posts on my other account.

  11. #11
    Script kiddie VENGEANCE MX's Avatar
    Join Date
    Jun 2004
    Location
    England
    Posts
    2,590
    If you're making a tile-based game, then perhaps you should give this tutorial a look:

    http://tonypa.pri.ee/tbw/index.html
    http://www.birchlabs.co.uk/
    You know you want to.

  12. #12
    Style Through Simplicity alillm's Avatar
    Join Date
    Mar 2004
    Location
    Wales
    Posts
    1,988
    [off topic] I see no delete [/off topic]

    Ali

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