-
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
-
Originally Posted by clairebear33
I have a fish, who swims through the sea controlled by the arrow keys
- Have you designed this part of the game already?
-
-
President
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
-
Senior Member
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!
-
Originally Posted by clairebear33
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
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|