Hey guys, I am trying to make a shape using Image.createRect and have it be clickable and I feel like I am missing out on something critical. Here is my shape class, the clicking works but only at 0,0 not at the location of the shape that I am spawning.
Here is the Shape.as
package entities
{
import net.flashpunk.FP;
import net.flashpunk.Entity;
import net.flashpunk.graphics.Image;
import net.flashpunk.graphics.Text;
import net.flashpunk.utils.Input;
public class theShape extends Entity
{
private var shape:Image;
public function theShape(posX:int, posY:int, color:int)
{
shape = Image.createRect(32, 32, color);
setHitbox(32, 32);
x = posX;
y = posY;
graphic = shape;
layer = 0;
}
override public function update():void
{
if (this.collidePoint(shape.x, shape.y, world.mouseX, world.mouseY))
{
if (Input.mouseReleased)click();
}
super.update();
}
public function click():void
{
trace("clicking shape");
}
}
}
Thanks guys!