PDA

View Full Version : [F8] Game using hitTest - odd behavior


cmwagner
02-23-2008, 09:23 PM
I tried to zip up my FLA file to attach it, but it's larger than the allowable size - give me your email address if you would like to look at the simplest version of this FLA file.

OK, I'm working on an assignment for class. We're supposed to be creating a hitTest matching game. One of the things we're supposed to do is make the game interesting. The only thing I could come up with is a myth matching game (match the god names to the pantheon)

All that is background info.

I've created the piece - and on my first god name I've put an if statement (based off what the teacher gave us for his example game).

onClipEvent (load) {
origX = this._x;
origY = this._y;
}
onClipEvent (enterFrame) {
// Make the movie clip dragable
this.onPress = function() {
startDrag(this);
};
this.onRelease = this.onReleaseOutside=function () {
this.stopDrag();
// see if the dropZone contains the center of this mc
if (_root.gDrop.hitTest(this._x, this._y, true)) {
// center it on the drop zone
this._x = _root.gDrop.gD1._x;
this._y = _root.gDrop.gD1._y;
} else {
// return it to its original location
this._x = origX;
this._y = origY;
}
};
}

Now, when I test the movie, I can click on the god name, move it/drag it, and drop it.

But when I drop it in the correct box (gD1 located within the gDrop box symbol), my god name completely and totally disappears.

Thinking that maybe I caused a stacking order problem, I made most of the rest of the interface semi-transparent to see if it was hanging out behind anything. Nope - it's just completely gone.

It returns when I hit the reset button, which has the following code on it:
on (release) {
zeus._x = zeus.origX;
zeus._y = zeus.origY;
}

(zeus being the instance name on the god name's movie clip)

And it returns the god name to it's original place and visibility - even though I didn't tell it to disappear.

What is going on? Or what might be going on? Or did I break something?

Thanks in advance!!

ASWC
02-24-2008, 05:10 AM
Most likely the problem comes from here:

this._x = _root.gDrop.gD1._x;
this._y = _root.gDrop.gD1._y;

to find out, just put a value instead that you know will leave your "god" on the stage and see if it goes away:

this._x = 200;
this._y = 200;

if it will go to 200/200, then you'll know what to fix...

cmwagner
02-24-2008, 06:32 AM
Yep, that was the problem! Thanks!

So, any clue what it was trying to do?

ASWC
02-24-2008, 07:17 AM
trace(_root.gDrop.gD1._x)
trace(_root.gDrop.gD1._y)

and you will know....