A Flash Developer Resource Site

Results 1 to 7 of 7

Thread: (Game "?") follow the cursor

  1. #1
    Member
    Join Date
    Nov 2001
    Posts
    49

    Question

    Hi All,

    Have a question,

    I have been helped greatly by Blanius's tut on setting an image to follow your cursor, but I need help with something different but similar......

    I'm building a game & I need to have the "baddies" chase my image (set to follow cursor) does this make sense?

    I have an image set to follow the X Y coordinates of the mouse pointer, but want to add charachters that will chase the pointer, I would like to use velocity & acceleration also but once again my tries have all failed.

    Any insight would be greatly appreciated.

    Thanks!
    Dub

  2. #2
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    trig

    Originally posted by goodwin2
    Hi All,

    Have a question,

    I have been helped greatly by Blanius's tut on setting an image to follow your cursor, but I need help with something different but similar......

    I'm building a game & I need to have the "baddies" chase my image (set to follow cursor) does this make sense?

    I have an image set to follow the X Y coordinates of the mouse pointer, but want to add charachters that will chase the pointer, I would like to use velocity & acceleration also but once again my tries have all failed.

    Any insight would be greatly appreciated.

    Thanks!
    Dub
    It's a little tricker than that... You will need to use trig math functions to determine the angle to your character

    look at the eyes follow cursor demo on my deadyeti site for a starter. http://deadyeti.com/blanius/eyes.html

    I understand what you want to do but have not actually done it.

    I belive it you use the code from the eyes example and set "rotational Velocity" you will get the desired result

  3. #3
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Well Sorry to say that upon checking this. It would seem that version 3.6 does not compile this example correctly.

    VERY FRUSTRATING!!!!!!!

    Ok so now I have to Re-Figure out how the rotation of an element is calculated. So Until I have time to figure out what has changed in handling of rotation and tangets this will not work......

    Sorry guys
    It's unfortunate that 3dfa math is not the same as in flash because it would be nice to use the vast information out there on the subject. I'm not good enough at the trig needed to figure it out on my own I learn this stuff from Flash5/FlashMX tutorials and port them over to 3dfa.

    Rob! What can I do....???

  4. #4
    Member
    Join Date
    Nov 2001
    Posts
    49
    Originally posted by blanius
    Well Sorry to say that upon checking this. It would seem that version 3.6 does not compile this example correctly.
    Sorry guys
    It's unfortunate that 3dfa math is not the same as in flash because it would be nice to use the vast information out there on the subject.
    Thank you very much for your attempts, your tries would have saved me hours & hours of vain attempts, (I'm stubborn like that)

    Well i could try an alternate route,
    Can you shed some light on how to drag an item automatically when the pointer moves over it?

    sort of like what a magnet would do.

  5. #5
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244

    sure

    in the list of actions add an If dragOn=true before the follow cursor routine and an "END" after


    Then in the main movie put an action
    Let dragOn=false

    Then make the object you want to follow a picture button and in the mouseover action put dragOn=true.

    In the Click Action you can put dragOn=false and move the cursor with code off the button

    Might work

  6. #6
    Member
    Join Date
    Nov 2001
    Posts
    49
    Originally posted by blanius
    Well Sorry to say that upon checking this. It would seem that version 3.6 does not compile this example correctly.

    VERY FRUSTRATING!!!!!!!
    Good news! ver #.7 does compile the eyes example,
    however the source file movie offered on your site has the "mouseX & mouseY" set backwards in the actions element.

    the eyes looked away from the mouse rather than follow it.
    funny & useful for that particular need!

    I swithced the actions & it compiled fine
    Thanks yet again Brett!

    on a prev post you suggested adding a rotational velocity to the object to get the desired effect, care to elaborate?
    would that need be implemented via javascript?

  7. #7
    KoolMoves Moderator blanius's Avatar
    Join Date
    Jul 2001
    Location
    Atlanta GA
    Posts
    5,244
    Originally posted by goodwin2
    Originally posted by blanius
    Well Sorry to say that upon checking this. It would seem that version 3.6 does not compile this example correctly.

    VERY FRUSTRATING!!!!!!!
    Good news! ver #.7 does compile the eyes example,
    however the source file movie offered on your site has the "mouseX & mouseY" set backwards in the actions element.

    the eyes looked away from the mouse rather than follow it.
    funny & useful for that particular need!

    I swithced the actions & it compiled fine
    Thanks yet again Brett!

    on a prev post you suggested adding a rotational velocity to the object to get the desired effect, care to elaborate?
    would that need be implemented via javascript?
    I havent tried this but releative.acceleration is the one you need (my mistake) Quoting the help file here:

    Relative acceleration is applied relative to the rotation of the element.
    This is particularly useful for game elements that change direction, but only accelerate in their forward direction, such as rockets and cars.

    For example:
    If an element has a rotation of 0, and a relative y acceleration is applied, it will move vertically.
    If an element has a rotation of 45 degrees, and a relative y acceleration is applied, it will move diagonally.
    If an element has a rotation of 90 degrees, and a relative y acceleration is applied, it will move horizontally.

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