A Flash Developer Resource Site

Results 1 to 6 of 6

Thread: Help would be appreciated!

  1. #1
    Junior Member
    Join Date
    Jan 2010
    Posts
    3

    Help would be appreciated!

    Hi there,

    I am completley new with flash and for one of my university modules I am to design a game.

    I have a fish, who swims through the sea controlled by the arrow keys and I want the fish to pick up other fish on it's way simply by swimming over them. I then want the fish that have been picked up to follow behind the main character.

    any advice would be appreciated. thank you!

    Claire

  2. #2
    Senior Member
    Join Date
    Oct 2009
    Posts
    117
    Quote Originally Posted by clairebear33 View Post
    I have a fish, who swims through the sea controlled by the arrow keys
    - Have you designed this part of the game already?

  3. #3
    Junior Member
    Join Date
    Jan 2010
    Posts
    3
    yes i have done!

  4. #4
    President PhobiK's Avatar
    Join Date
    Jan 2005
    Location
    Guatemala
    Posts
    918
    You can do it by putting a hitTest in the fish that are going to follow your main character. For example, you should write something like this in the first frame of your fish mc's:
    Code:
    var following:Boolean = false; // not following yet
    
    OnEnterFrame = function () {
    if (hitTest(_root.mainFish)) { // if this hits the main character set "following" to true
    following = true;
    }
    if (following) { // if you have been hit already
    _x += ((_root.mainFish._x - 30) - _x) * 0.3; // -30 is to follow the fish and not be over it
    _y += (_root.mainFish._y - _y) * 0.3;
    }
    }
    That's AS2, don't have a clue if you're using AS3. Hope it helps.
    This is MC. His _parents sent him to stop() by the super market to buy some _root beer if he wanted to gotoAndPlay() with his friends at the park later.

    This is my Blog!... The gaming Process
    Please check out my site: Giddel Creations

  5. #5
    Senior Member Pazil's Avatar
    Join Date
    Sep 2006
    Location
    Ontario, Canada
    Posts
    913
    Just do some simple distance : distance = Math.sqrt( fish.x * fish.x + fish.y * fish.y);?

    Look up flock/group/herding AI, that's to coordinate all the fishies followin ya. I gotta go now, but as soon as I get the chance, I'll pop you some links.
    WIP-ZOMBIES

    I love vegetarians! More meat for the rest of us!

  6. #6
    Senior Member
    Join Date
    Oct 2009
    Posts
    117
    Quote Originally Posted by clairebear33 View Post
    yes i have done!
    Is it possible for you to post the code on the work that you've done already? That will give us an idea of the context.

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