moveCollide question!


(Nate ) #1

Okay guys so I decided to go a different route for setting up my platformer! I found a tutorial dated from 2011, however it allowed me to set up my basics for my game. I didn’t realize that I was working with an older version of FlashPunk until I was done setting everything up.

After switching everything seems to be in working order except two function in my Player.as class.

The error I am getting is this:

"col: 28 Error: Incompatible override."

Basically inside of the Player.as update function I have these two functions:

override public function moveCollideX(e:Entity):void
{
	xSpeed = 0;
}
override public function moveCollideY(e:Entity):void
{
	ySpeed = 0;
}

Let me know what you guys think! Thank you!


(Ultima2876) #2

The functions need to return Boolean, like so:

override public function moveCollideX(e:Entity): Boolean
    {
        xSpeed = 0;
        return true;
    }
    override public function moveCollideY(e:Entity): Boolean
    {
        ySpeed = 0;
        return true;
    }

To override a function it needs to have the same arguments, accessibility and return type as the function it wants to override. These functions are defined as so in Entity.as:

     /**
	 * When you collide with an Entity on the x-axis with moveTo() or moveBy().
	 * @param	e		The Entity you collided with.
	 */
	public function moveCollideX(e:Entity):Boolean
	{
		return true;
	}

	/**
	 * When you collide with an Entity on the y-axis with moveTo() or moveBy().
	 * @param	e		The Entity you collided with.
	 */
	public function moveCollideY(e:Entity):Boolean
	{
		return true;
	}

Thus your override functions must be public, have one argument that is of the Entity type and must return Boolean in order to be compatible.


[SOLVED] Collision for max 30 pixel size Images
(Nate ) #3

Okay just changed to have it return the boolean value and it worked like a charm!

thank you so much! :smiley: