Professional Web Applications Themes

Some help with coordinates please! - Macromedia Flash Actionscript

Hullo! Ok, so, I have this friend (clichè? no, no, I swear it's true!) that has a problem. I thought i could help her but I couldn't after all. So the problem is: she has this thingamajig that you can guide around on the scene (I think it's a fish). There are also a few barriers around on the scene. When this fish or something swims into one of these barriers, it is supposed to activate a movie clip when the x and y values of the fish match the values of the x and y for the barriers. Waiting ...

  1. #1

    Default Some help with coordinates please!

    Hullo!

    Ok, so, I have this friend (clichè? no, no, I swear it's true!) that has a problem. I thought i could help her but I couldn't after all.

    So the problem is: she has this thingamajig that you can guide around on the scene (I think it's a fish). There are also a few barriers around on the scene. When this fish or something swims into one of these barriers, it is supposed to activate a movie clip when the x and y values of the fish match the values of the x and y for the barriers.

    Waiting in suspense
    ....


    happyblimp webforumsuser@macromedia.com Guest

  2. #2

    Default Re: Some help with coordinates please!

    "happyblimp" <webforumsusermacromedia.com> wrote in message
    news:buf43o$mg2$1forums.macromedia.com...
    > Hullo!
    >
    > Ok, so, I have this friend (clichè? no, no, I swear it's true!) that has a
    problem. I thought i could help her but I couldn't after all.
    >
    > So the problem is: she has this thingamajig that you can guide around on
    the scene (I think it's a fish). There are also a few barriers around on the
    scene. When this fish or something swims into one of these barriers, it is
    supposed to activate a movie clip when the x and y values of the fish match
    the values of the x and y for the barriers.
    >
    > Waiting in suspense
    > ...
    See some examples at flashkit:
    [url]http://www.flashkit.com/tutorials/Games/[/url]

    hittest can be used to detect collision of an object with a barrier.
    // see if the ball has hit the square
    if(_root.ball, hittest(_root.square)){
    trace("ball intersects square");
    }


    tralfaz Guest

  3. #3

    Default Re:Some help with coordinates please!

    um, hi,

    Tell "your friend" that this may be interpreted in two ways:

    First of all, each clip (the fish and the barrier) have a reference point which is usually the center of the clip, and this point is usually what people refer to as the x,y coordinate of the clip, so, the interpretations are:

    1) You (I mean, "your friend") wants the x,y values of the fish to line up exactly with the x,y values of the barrier, which would mean that the movie clip is activated when the middle of the fish lines up with the middle of the barrier. I doubt this is what you want...

    2) Your friend wants some rudimentary collision detection to determine when the fish hits the barrier at all (e.g. The nose, or the tail, or the fin). SO I will explain this one:

    The easiest way is to define a 'bounding box' for each object. Define a box (and the coordinates of it) that surround the fish. Also define one that surrounds the barrier. Once this is done, collisions are detected if these two boxes ever intersect.

    You can either:
    a) Call this function from the main timeline, passing if the values of the fish and each barrier to check for a collision in turn - or -
    b) Contain this function inside the barrier itself. The function checks for a collision between the fish (of which we presume there is only 1) and the barrier clip from which the function is called.

    I recoomend (b) if there are few barriers because then collsion detection is automatic and you can simply drop in more barriers with no extra code. But if there are too many barriers, the function will be run inside each barrier and slowr computers will have a hard time coping.

    Hope it helps,
    Pea


    Pea webforumsuser@macromedia.com Guest

Similar Threads

  1. Convert user space coordinates to device coordinates
    By Florin_O@adobeforums.com in forum Adobe Acrobat SDK
    Replies: 2
    Last Post: January 27th, 07:16 AM
  2. x and y coordinates
    By Stephen_Field@adobeforums.com in forum Adobe Illustrator Windows
    Replies: 4
    Last Post: March 8th, 02:33 AM
  3. colorpicker with uv coordinates
    By hondo3000 in forum Macromedia Director 3D
    Replies: 2
    Last Post: December 23rd, 02:25 PM
  4. Mouse Coordinates -- off .swf
    By eljefeloco101 webforumsuser@macromedia.com in forum Macromedia Flash Actionscript
    Replies: 3
    Last Post: February 4th, 06:23 PM
  5. Passing coordinates
    By Ray at home in forum ASP
    Replies: 7
    Last Post: October 28th, 02:45 PM

Bookmarks

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139