Home Tutorials Forums Articles Blogs Movies Library Employment Press
Old 03-08-2002, 09:07 AM   #1
cuba
Registered User
 
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
Question hitTest for a game

Hello

I'm swiss. I hope you'll understand my english. I have the following problem: I'm creating a game. I have a flying helicopter
which can land on mountains or platforms. I'd like to attach a
charakter (man) on a mountain. I want to pick up the man with the helicopter, and drop it again on a different area. I have the
following script attached to the "man" charakter:
onClipEvent(enterFrame) {
if(hitTest("_parent.heli")) {
_x=_parent.heli._x;
_y=_parent.heli._y;
(_parent.heli._height/2);
}
This works to attach the man to the heli, but it hides the charakter
behing the heli, i want it to be attached under the heli.
What do I have to change???

How can I drop the charakter over a different area ???

thanks in advance for any help, tips or examples

regards
cuba
cuba is offline   Reply With Quote
Old 03-08-2002, 09:41 AM   #2
sfa
The Placid Casual
 
sfa's Avatar
 
Join Date: Oct 2001
Location: Malta
Posts: 1,024
Default

You either have to move the man character inside the movie or change the line _y=_parent.heli._y; to _y=_parent.heli._y + 10;(change ten depending on the size of the helicopter). The x will be defined from the centre of the movie. I would go for the first option and keep it simple.

SFA
sfa is offline   Reply With Quote
Old 03-08-2002, 09:41 AM   #3
IFZen
Even graphists R objects
 
IFZen's Avatar
 
Join Date: Jun 2001
Location: Paris
Posts: 273
Default

Hi cuba,

If your rescued people are attached mc's, you should consider at least two scenarios for them. The first one as you wrote it allow you to find them on mountains. Then, when they hit the chopper, you could destroy their first occurence and attach them again into the chopper clip (there you also could place their clips between a front clip of your chopper and a background clip to give a good illusion they seat inside the chopper).

At the end you will also have to imagine a third scenario when you arrive at your base, allowing them to get off the chopper and have a nice cup of tea into the base.

One good point with that way is that you won't have to perpetually execute your enterFrame code after you rescued your people. Into the chopper they won't have to do nothing but wait for safe landing.

Hope you understood me.
BZen
__________________
Oh Lord, shut me down !
IFZen is offline   Reply With Quote
Old 03-08-2002, 11:26 AM   #4
cuba
Registered User
 
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
Smile

thanks i will try this. but how can i drop the "character", with
_droptarget ???? or do you have another idea???

thanks a lot

regards
cuba
cuba is offline   Reply With Quote
Old 03-08-2002, 12:48 PM   #5
IFZen
Even graphists R objects
 
IFZen's Avatar
 
Join Date: Jun 2001
Location: Paris
Posts: 273
Default

You can use the same hitTest method on your base to check when your chopper lands and then automaticly launch an animation showing your rescued characters being saved. Just before destroy their instancies into the chopper.

Hope it helps,
BZen
__________________
Oh Lord, shut me down !
IFZen is offline   Reply With Quote
Old 03-10-2002, 08:40 AM   #6
cuba
Registered User
 
Join Date: Mar 2002
Location: zurich, switzerland
Posts: 65
Unhappy helicopter game

Hi mozilla

I tried to attach your sample script to the character man, but
it doesn't work. I think i need to attach a script to the helicopter,
because it can land without any problem.

I didn't understood the "trace"-thing, i always had a debugger
window: with the "not allowed to land window"...

I hope that you understand me...

Thanks again for your kind help !






Hi again (Thanks Mozilla for your reply)

I have still the problem, that it's possible to land, without going
to save the person (character:man)
If the player wants to land, without having saved the person, a
message should appear: "not allowed to land, save the person"
I have the following actions for the helicopter to land:
function checkForLand () {
landed = true;
for (i=0; i<footPoints.length; i++) {
footDown = false;
for (j=0; j<bars.length; j++) {
if (bars[j].hitTest(heli._x+footPoints[i].x, heli._y+footPoints[i].y, true)) {
footDown = true;
break;
}
}
if (!footDown) {
landed = false;
break;
}
}
if (heli.dy>3.0) {
landed = false;
}
if (landed) {
gotoAndPlay (_currentframe+1);
gameLevel++;

And these actions are for the character:

onClipEvent (enterFrame) {
if (hitTest("_parent.heli")) {
_x = _parent.heli._x;
_y = _parent.heli._y+50;
(_parent.heli._height/2);
}
}
onClipEvent (enterFrame) {
if (hitTest("_parent.hospital1")) {
_x = _parent.hospital1._x-0;
_y = _parent.hospital1._y-1;
(_parent.hospital1._height/2);
}
}
Thanks in advance for your help... regards from zurich, switzerland
cuba

Last edited by cuba; 03-10-2002 at 06:26 PM.
cuba is offline   Reply With Quote
Old 03-10-2002, 12:48 PM   #7
mozilla
mimi
 
mozilla's Avatar
 
Join Date: Jun 2001
Location: the fruhling
Posts: 161
Default

did you try? what didn't work? please specify problem. (or post fla)

greeZ
mozilla is offline   Reply With Quote
Reply


Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
[AS2] hitTest problem, Game Bomb VVV Gaming and Game Development 1 09-02-2004 01:55 PM
hitTest in a little game mullwaden Gaming and Game Development 7 11-29-2003 12:27 PM
game hitTest problem masha Gaming and Game Development 3 03-20-2003 05:42 PM
basic game problems, score board, hitTest sounds, and a big one ninjacore Gaming and Game Development 3 01-03-2003 02:05 PM
game hittest problem marco66 Gaming and Game Development 7 10-21-2002 03:11 PM


All times are GMT. The time now is 01:46 PM.

///
Follow actionscriptorg on Twitter

 


Powered by vBulletin® Version 3.8.5
Copyright ©2000 - 2014, Jelsoft Enterprises Ltd.
Ad Management plugin by RedTyger
Copyright 2000-2013 ActionScript.org. All Rights Reserved.
Your use of this site is subject to our Privacy Policy and Terms of Use.