OK I think I have cracked it! I was going in the right direction earlier
with the localToGlobal thing
This is what I have done to fix it
[code]
var myPoint = new Object();
myPoint.x = _parent.game_mc.player_mc._x;
myPoint.y = _parent.game_mc.player_mc._y;
trace ("myPoint.x before = " + myPoint.x);
trace ("myPoint.y before = " + myPoint.y);
_parent.game_mc.localToGlobal(myPoint);
trace ("myPoint.x after = " + myPoint.x);
trace ("myPoint.y after = " + myPoint.y);
if (_level0.game_mc.bg_mc.hitTest(myPoint.x, myPoint.y,
true)) {
trace ("HIT RIVER BANK ****************");
}
[/code]
Thanks for all the help. What a waste of a day trying to fix one bug!!
Hi Paul,
The problem is that you attach it as Player_Object and refer to it as
mcDolphin.
Changing:
if (game_mc.bg_mc.hitTest(game_mc.mcDolphin._x, game_mc.mcDolphin._y, true))
{
Into:
if (game_mc.bg_mc.hitTest(game_mc.Player_Object._x,
game_mc.Player_Object._y, true)) {
Solves the problem.
Greetz,
Bernard
> -----Oorspronkelijk bericht-----
> Van: [EMAIL PROTECTED]
> [mailto:[EMAIL PROTECTED] Namens Paul Steven
> Verzonden: maandag 24 april 2006 16:37
> Aan: Flashcoders mailing list
> Onderwerp: [Flashcoders] hitTest difference between attached
> mc and one placedon stage in authoring
>
> I am having problems making the hitTest function work with a
> movie clip attached from the library
>
> Basically I am making a game that involves a dolphin swimming
> up a river and I want to detect when the dolphin hits the river bank.
>
> The following works fine when the dolphin is placed on stage
> in authoring mode
>
> if(mcBanks.hitTest(mcDolphin._x, mcDolphin._y, true){
>
> //doplhin has hit
>
> }
>
> See http://www.mediakitchen.co.uk/dolphin.html
>
> Whereas when I attach the dolphin using attachMovie it does
> not work and infact detects a collision at all times:
>
> See See http://www.mediakitchen.co.uk/dolphin_new.html
>
> Any ideas why this should not work when the dolphin is attached.
>
> Here is a link to the fla incase you should want to see the code
>
> http://www.mediakitchen.co.uk/dolphin_new.zip
>
> Any advice much appreciated
>
> Thanks
>
> Paul
>
> _______________________________________________
> [email protected]
> To change your subscription options or search the archive:
> http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
>
> Brought to you by Fig Leaf Software
> Premier Authorized Adobe Consulting and Training
> http://www.figleaf.com http://training.figleaf.com
>
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com
_______________________________________________
[email protected]
To change your subscription options or search the archive:
http://chattyfig.figleaf.com/mailman/listinfo/flashcoders
Brought to you by Fig Leaf Software
Premier Authorized Adobe Consulting and Training
http://www.figleaf.com
http://training.figleaf.com