i am following Zachary Lewis’s tutorial, Making Games With FlashPunk: Episode 2 - Adding Players and Enemies, and i got to the point where i need to handel collision i type the code in the video i get an error saying:
"C:\Users\???\Documents\RGB\src\Player.as(24): col: 8 Error: Call to a possibly undefined method collide. if (collide("enemy", x, y)) { ^ C:\Users\????\Documents\RGB\src\Player.as(24): col: 25 Error: Access of undefined property x. if (collide("enemy", x, y)) { ^ C:\Users\????\Documents\RGB\src\Player.as(24): col: 28 Error: Access of undefined property y. if (collide("enemy", x, y)) { ^ C:\Users\????\Documents\RGB\src\Player.as(25): col: 11 Error: Access of possibly undefined property color through a reference with static type Class. Image.color = 000000 ^ C:\Users\????\Documents\RGB\src\Player.as(28): col: 9 Error: Access of possibly undefined property color through a reference with static type Class. Image.color = 0xff0000 ^ Build halted with errors (fcsh)."
i back to double and triple check if i missed something but i can’t figure out what.
package
{
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.utils.Input;
import net.flashpunk.utils.Key;
import net.flashpunk.FP;
public class Player extends Entity
{ [Embed(source = "../assets/R.png")]private const PLAYER:Class;
public var image:Image;
public function Player()
{
graphic = new Image(PLAYER);
setHitbox(20, 20, 0, 0);
type = "player";
}
override public function update():void
{
if (Input.check(Key.LEFT)) { x -= 5; }
if (Input.check(Key.RIGHT)) { x += 5; }
if (Input.check(Key.UP)) { y -= 5; }
if (Input.check(Key.DOWN)) { y += 5; }
}
if (collide("enemy", x, y)) {
Image.color = 000000
}
else(
Image.color = 0xff0000
)
}
super.update();
}
I know my code isn’t exactly the same as the video but im trying to make my own game based of it.