|
-
Game not tracking hit and miss
I have built a whack a mole style game that works (with some help from this forum).
I now want to place that game inside another flash site. I've tried adding it as an extern swf (on click - load movie) and as a movieclip inside the new flash site. The game works in both methods (it runs a bit slow and jerky - but thats another problem) but the game does not count the times you hit the mole and the times you miss.
My guess is that the coding isn't specific enough and there is confussion in regestering the hits because of the various levels of the flash site (after all - it works as a stand alone game.)
This is the code for changing the mouse graphic and the actions:
stop();
Mouse.hide();
mallet.stop();
mallet._x = _xmouse;
mallet._y = _ymouse;
function checkHits(mc) {
point = {x:mc._x, y:mc._y}
mc._parent.localToGlobal(point);
if (_root.hole.pancake.hitTest(point.x, point.y)) {
trace("hit");
}
}
mallet.onMouseDown = function() {
this.gotoAndStop(2);
checkHits(this.head);
this.onMouseUp = function() {
this.gotoAndStop(1);
};
};
mallet.onMouseMove = function() {
mallet._x = _xmouse;
mallet._y = _ymouse;
};
This is the code for the objects that you hit:
if (smacked) {
_root.hits++;
} else {
_root.misses++;
}
This is the code when game time has ended:
if ( _root.hits> _root.misses ) {
_root.gotoAndPlay("win");
} else {
_root.gotoAndPlay("lose");
}
I've tried replacing the use of '_root' with 'this' which didn't make a difference. I've tried putting the Mouse action script in the main flash level instead of the game movie clip - but that didn't work.
Thanks for any help.
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
|