-
Senior Member
That's ridiculous. Totally unneeded. He's obviously not hitTesting the entire babyMCs against eachother. That's the only problem. hitTest works fine.
The code you wrote IS hitTest!
Last edited by devnull_2k; 04-10-2003 at 08:36 PM.
The future belongs to those who prepare for it today.
-
ism
i think he might be talkin about this;
http://www.nlc.net.au/~oceana/games/collision3.swf
http://www.nlc.net.au/~oceana/games/collision3.zip
(try rotating both boxes about 45 degrees and then moving them so they are right next to each other, parallel, but not touching)
when you rotate an mc you distort it's bounding box and therefore introduce the possibility of a hittest returning true even though the two objects arn't touching. now the getbounds method is not perfect, it's just a little more accurate.
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Timetravelling Superhero
Originally posted by devnull_2k
That's ridiculous. Totally unneeded. He's obviously not hitTesting the entire babyMCs against eachother. That's the only problem. hitTest works fine.
The code you wrote IS hitTest!
My code makes the babies exert force on each other when they hit.
From here to infinity,
A J I N F I N I T Y
-
Senior Member
The future belongs to those who prepare for it today.
-
ism
me too
Graphics Attract, Motion Engages, Gameplay Addicts
XP Pro | P4 2.8Ghz | 2Gb | 80Gb,40Gb | 128Mb DDR ATI Radeon 9800 Pro
-
Lunatic
Sorry for interupting
This is my hitTest: otherbaby.hitTest(_x,_y,true)
It's not perfect, but also not to complicated. The bounds idea is good, but I don't want the babies to get stuck. The shape of the babies is to complicated. And as adityadennis says, it's a side projects, so I keep it this way.
Atleast here's an update:
http://regnerus.port5.com/babybattle/babybattle.htm
- Sound added
- Other picto's for the power-ups
- A chair added; I want more objects, to they're fighting in a livingroom or something
I removed the sterio panning (AJ Infinity, thanx for the words ), because it influences all the sound.
-
Timetravelling Superhero
My code wasn't that complicated. It didn't test the whole contour of the babies, it just checked to see if their bounding boxes were colliding and made them apply force on each other so they wouldn't walk through each other (note they stop walking through each other when their centers touch, because of hitTest(x, y, true).) I suggest multiple getBounds() methods only for people who are good with math, though. hitTest() is a simple method. Read the collision detection chapters in Physics for Game Developers and Flash MX Game Design Demystified.
Code:
if(baby_1.hitTest(baby_2){
if(baby_1._y > baby_2._y){
baby_2._y = baby_1.getBounds(_root).yMax + 2;
} else if(baby_1._y < baby_2._y){
baby_2._y = baby_1.getBounds(_root).yMin - 2;
}
if(baby_1._x > baby_2._x){
baby_2._y = baby_1.getBounds(_root).xMax + 2;
} else if(baby_1._x < baby_2._x){
baby_2._y = baby_1.getBounds(_root).xMin - 2;
}
}
From here to infinity,
A J I N F I N I T Y
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
|