Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 492551
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 13, 20262026-05-13T02:07:26+00:00 2026-05-13T02:07:26+00:00

I’m currently building the damage mechanic for my game. Two classes handle this, the

  • 0

I’m currently building the damage mechanic for my game. Two classes handle this, the ‘hurt’ class, and the ‘collision’ class. The hurt class passes an instance of itself to the ‘hurtCollision’ method of the collision class, so that the collision class can detect a collision between the player and that instance of hurt (which is a display object). When I try to access that function however, I get this error:

1061: Call to a possibly undefined method hurtCollision through a reference with static type Class.

Here are the two classes:

The collision class (you can just ctrl f to hurtCollision):

package

{

import flash.display.MovieClip;

public class Collision extends MovieClip
{
    private var e:*;
    static public var _playerX:*;
    static public var _playerY:*;
    private var HIT_BOTTOM_1X:Number;
    private var HIT_BOTTOM_2X:Number;
    private var HIT_BOTTOM_3X:Number;
    private var HIT_TOP_1X:Number;
    private var HIT_TOP_2X:Number;
    private var HIT_TOP_3X:Number;
    private var HIT_R_1X:Number;
    private var HIT_R_2X:Number;
    private var HIT_R_3X:Number;
    private var HIT_L_1X:Number;
    private var HIT_L_2X:Number;
    private var HIT_L_3X:Number;
    private var HIT_BOTTOM_1Y:Number;
    private var HIT_BOTTOM_2Y:Number;
    private var HIT_BOTTOM_3Y:Number;
    private var HIT_TOP_1Y:Number;
    private var HIT_TOP_2Y:Number;
    private var HIT_TOP_3Y:Number;
    private var HIT_R_1Y:Number;
    private var HIT_R_2Y:Number;
    private var HIT_R_3Y:Number;
    private var HIT_L_1Y:Number;
    private var HIT_L_2Y:Number;
    private var HIT_L_3Y:Number;

    public function Collision(enginePass:*)
    {       
    e = enginePass;
    }
    public function detectCollisions(object:*):void
    {
        _playerX = e._player.x;
        _playerY = e._player.y;
        HIT_BOTTOM_1X = object.x - object.width/2;
        HIT_BOTTOM_2X = object.x;
        HIT_BOTTOM_3X = object.x + object.width/2;
        HIT_TOP_1X = object.x - object.width/2;
        HIT_TOP_2X = object.x;
        HIT_TOP_3X = object.x + object.width/2;
        HIT_R_1X = object.x + object.width/2;
        HIT_R_2X = object.x + object.width/2;
        HIT_R_3X = object.x + object.width/2;
        HIT_L_1X = object.x - object.width/2;
        HIT_L_2X = object.x - object.width/2;
        HIT_L_3X = object.x - object.width/2;

        HIT_BOTTOM_1Y = object.y + object.height/2;
        HIT_BOTTOM_2Y = object.y + object.height/2;
        HIT_BOTTOM_3Y = object.y + object.height/2;
        HIT_TOP_1Y = object.y - object.height/2;
        HIT_TOP_2Y = object.y - object.height/2;
        HIT_TOP_3Y = object.y - object.height/2;
        HIT_R_1Y = object.y + object.height/2 - object.height/4;
        HIT_R_2Y = object.y;
        HIT_R_3Y = object.y - object.height/2 + object.height/4;
        HIT_L_1Y = object.y + object.height/2 - object.height/4;
        HIT_L_2Y = object.y;
        HIT_L_3Y = object.y - object.height/2 - object.height/4;

        if(e._ground.hitTestPoint(HIT_BOTTOM_1X,HIT_BOTTOM_1Y,true) || e._ground.hitTestPoint(HIT_BOTTOM_2X,HIT_BOTTOM_2Y,true) 
        || e._ground.hitTestPoint(HIT_BOTTOM_3X,HIT_BOTTOM_3Y,true))
        {
            e._touchGround = true;
            if(e._vy < 0)
            {
                e._vy = 0;
            }
        }
        if(e._ground.hitTestPoint(HIT_TOP_1X,HIT_TOP_1Y,true) || e._ground.hitTestPoint(HIT_TOP_2X,HIT_TOP_2Y,true) 
        || e._ground.hitTestPoint(HIT_TOP_3X,HIT_TOP_3Y,true))
        {
            e._jump = false;
            e._vy = -(e._vy) - 5;
        }

         if(e._ground.hitTestPoint(HIT_R_1X,HIT_R_1Y,true) || e._ground.hitTestPoint(HIT_R_2X,HIT_R_2Y,true) 
        || e._ground.hitTestPoint(HIT_R_3X,HIT_R_3Y,true))
        {
            if(e._vx > 0)
            {
                e._vy += e._vx;
            }
            if(e._ground.hitTestPoint(HIT_TOP_3X, HIT_TOP_3Y, true))
            {
                if(e._vx > 0)
                {
                e._vx = -(e._vx) *2;
                }
            }
        }
        if(e._ground.hitTestPoint(HIT_L_1X,HIT_L_1Y,true) || e._ground.hitTestPoint(HIT_L_2X,HIT_L_2Y,true) 
        || e._ground.hitTestPoint(HIT_L_3X,HIT_L_3Y,true))
        {
            if(e._vx < 0)
            {
                e._vy += Math.abs(e._vx);
            }
            if(e._ground.hitTestPoint(HIT_TOP_1X, HIT_TOP_1Y, true))
            {
                if(e._vx < 0)
                {
                e._vx = -(e._vx) *2;
                }
            }
        }
        if(e._ground.hitTestPoint(HIT_TOP_3X, HIT_TOP_3Y, true) && e._ground.hitTestPoint(HIT_BOTTOM_3X, HIT_BOTTOM_3Y, true))
        {
            e._vy += 20;
        }
        if(e._ground.hitTestPoint(HIT_TOP_1X, HIT_TOP_1Y, true) && e._ground.hitTestPoint(HIT_BOTTOM_1X, HIT_BOTTOM_1Y, true))
        {
            e._vy += 20;
        }
        if(e._ground.hitTestPoint(e._player.x,e._player.y, true))
        {
            e._vy = -(e._vy);
            e._vx = -(e._vx);
        }
        else
        {
            if(!(e._ground.hitTestPoint(HIT_BOTTOM_1X,HIT_BOTTOM_1Y,true) || e._ground.hitTestPoint(HIT_BOTTOM_2X,HIT_BOTTOM_2Y,true) 
        || e._ground.hitTestPoint(HIT_BOTTOM_3X,HIT_BOTTOM_3Y,true)))
            {
            e._vy -= 1;
            e._touchGround = false;
            }
        }
    }

    public function hurtCollision(hurtObject:*)
    {
        if(hurtObject.hitTestPoint(HIT_BOTTOM_1X,HIT_BOTTOM_1Y,true) || hurtObject.hitTestPoint(HIT_BOTTOM_2X,HIT_BOTTOM_2Y,true) 
        || hurtObject.hitTestPoint(HIT_BOTTOM_3X,HIT_BOTTOM_3Y,true))
        {
            e.hurtPlayer();
        }
        if(hurtObject.hitTestPoint(HIT_TOP_1X,HIT_TOP_1Y,true) || hurtObject.hitTestPoint(HIT_TOP_2X,HIT_TOP_2Y,true) 
        || hurtObject.hitTestPoint(HIT_TOP_3X,HIT_TOP_3Y,true))
        {
            e.hurtPlayer();
        }

         if(hurtObject.hitTestPoint(HIT_R_1X,HIT_R_1Y,true) || hurtObject.hitTestPoint(HIT_R_2X,HIT_R_2Y,true) 
        || hurtObject.hitTestPoint(HIT_R_3X,HIT_R_3Y,true))
        {
            e.hurtPlayer();
        }
        if(hurtObject.hitTestPoint(HIT_L_1X,HIT_L_1Y,true) || hurtObject.hitTestPoint(HIT_L_2X,HIT_L_2Y,true) 
        || hurtObject.hitTestPoint(HIT_L_3X,HIT_L_3Y,true))
        {
            e.hurtPlayer();
        }
    }
}

}

The hurt class:

package

{
import flash.display.MovieClip;
import flash.events.Event;
import Collision;

public class Hurt extends MovieClip
{
    public function Hurt() 
    {
        addEventListener(Event.ENTER_FRAME, enterFrame);
    }
    private function enterFrame(e:Event)
    {
        Collision.hurtCollision(this);
    }
}

}

EDIT: Just to let you all know, e.hurtPlayer is just the document class method that controls the player’s health.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-13T02:07:27+00:00Added an answer on May 13, 2026 at 2:07 am

    Your problem lies here:

    Collision.hurtCollision(this);
    

    hurtCollision isn’t a class method, it’s an instance method. If you want Collision to be more like a utility class (as opposed to having to create instances to use the methods) then you probably want to do public static function ... instead of just public function.

    Read up on class methods for more.

    Reading your code more closely you’ve designed it in such a way that the constructor takes a parameter that you use in the methods. This will either need to be rethought (pass that thing into the methods themselves, maybe?) or you can just go the instance route:

    new Collision( e ).hurtCollision( this );
    

    … You might want to keep the instance around longer than just for the one call if you use it a lot, of course.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
For some reason, after submitting a string like this Jack’s Spindle from a text
this is what i have right now Drawing an RSS feed into the php,
I want use html5's new tag to play a wav file (currently only supported
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
We're building an app, our first using Rails 3, and we're having to build
I have this code: - (void)parser:(NSXMLParser *)parser foundCDATA:(NSData *)CDATABlock { NSString *someString = [[NSString

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.