Copy link to clipboard
Copied
so i want to make it whenever evilShadow touches charShadow, dark is added. the whole function is an enter frame function. and whenever evilshadow does not touch charShadow there shouldnt be any dark.
if(evilShadow.hitTestObject(charShadow))
{
if(fadePresent == false)
{
dark = new DarkFade;
dark.scaleX = 4;
dark.scaleY = 4;
addChild(dark);
fadePresent = true;
}
}
if((evilShadow.hitTestObject(charShadow)==false)&&(contains(dark)))
{
fadePresent = false;
removeChild(dark);
}
everythin works fine but this error shows up
TypeError: Error #2007: Parameter child must be non-null.
at flash.display::DisplayObjectContainer/contains()
at HorrorGame/checkforHits()
i fixed the errors with another variable
i took out if(contains(dark)) to if(darkhere == true)
darkhere boolean tells if dark is present on the screen. idk why contains doesnt work tho
Copy link to clipboard
Copied
use:
if(evilShadow.hitTestObject(charShadow))
{
if(!dark||!dark.stage)
{
dark = new DarkFade();
dark.scaleX = 4;
dark.scaleY = 4;
addChild(dark);
}
}
if(!evilShadow.hitTestObject(charShadow)&&dark&dark.stage)
{
removeChild(dark);
}
Copy link to clipboard
Copied
i put in ur codes and i get this
1067: Implicit coercion of a value of type DarkFade to an unrelated type Number.
1067: Implicit coercion of a value of type flash.display:Stage to an unrelated type Number.
from
if(!evilShadow.hitTestObject(charShadow)&&dark&dark.stage)
what do the exclamation marks do?
Copy link to clipboard
Copied
i fixed the errors with another variable
i took out if(contains(dark)) to if(darkhere == true)
darkhere boolean tells if dark is present on the screen. idk why contains doesnt work tho
Copy link to clipboard
Copied
the ! is a negation (or not) operator.
there's a typo. that should be
if(!evilShadow.hitTestObject(charShadow)&&dark&&dark.stage)