Skip to main content
Participant
February 3, 2012
Answered

hi i need help with this

  • February 3, 2012
  • 1 reply
  • 636 views

ok so i'm using flash to program obviously and i am trying to initialize a collision for a roof it says Collision has not been declared.

i have

   

    import flash.display.MovieClip;

    import flash.events.KeyboardEvent;

    import flash.ui.Keyboard;

    import flash.events.Event;

    public class Main_Ninja extends MovieClip

    {

        var vx:int;

        var vy:int;

        var score:uint;

        var collisionHasOccurred:Boolean;

        var playerHasMoney:Boolean;

i am trying to initialize

Collision.block(player, roof);

but when i try to initialize that it gets stuck in an infinite loop for this

if (player.hitTestObject(enemy))

            {

                enemy.gotoAndStop(2);

                health.meter.width--;

                if (! collisionHasOccurred)

                {

                    score++;

                    messageDisplay.text = String(score);

                    collisionHasOccurred = true;

                }

            }

            else

            {

                enemy.gotoAndStop(1);

                collisionHasOccurred = false;

            }

please help me if you can.

This topic has been closed for replies.
Correct answer kglad

"pretty much the same" doesn't work when talking about executable code.  you can miss one, what appears to you to be a small detail, and completely break your code so nothing works.

you're missing something.  for example, whoever you're copying probably has a file (named Collision.as) in their class path.  you need that file.

1 reply

kglad
Community Expert
Community Expert
February 3, 2012

what's Collision?  is that a class that you created?  if so, is block() a static method of that class?

Participant
February 3, 2012

to be honest im following my instructors code and his works my code is pretty much the exact same as his. we have an fla file we are referencing and in his code he doesnt have Collision declared anywhere except for collisionHasOccurred. I am trying to make so that the player collides with a brick called roof. Above i have what I have declared and in the fla file I have player, enemy, and roof. I have a collision detection setup for the player and enemy for if the player touches the enemy the enemy animates a bit, but i cant get that collision to work. Am i suppose to declare it? did you wanna see the code? its all for a video game design college course.

kglad
Community Expert
kgladCommunity ExpertCorrect answer
Community Expert
February 3, 2012

"pretty much the same" doesn't work when talking about executable code.  you can miss one, what appears to you to be a small detail, and completely break your code so nothing works.

you're missing something.  for example, whoever you're copying probably has a file (named Collision.as) in their class path.  you need that file.