Hi, just getting back into coding after after a few years. I have a question about collision with the spritemap. Basically I can create a bullet and then have the target check to see if it is hit. This works fine.
Working code:
Bullet Class:
public function Bullet(x:int, y:int )
{
this.x = x;
this.y = y;
var img:Image = Image.createCircle(8,0x00FF00, 1);
graphic = img;
setHitboxTo(img);
type = "bullet";
}
Enemy Class checks:;
var bullet:Bullet = collide("bullet", x, y) as Bullet;
if (bullet)
{
HUD.score++;
bullet.destroy();
destroy();
}
So now I want to add a sprite. This doesn’t work when I turn the bullet class to a spritemap.
Bullet Class (new one with spritemap)
public function Bullet1(x:int, y:int )
{
graphic = new Spritemap(ANIMATION, 64, 64);
this.x = x;
this.y = y;
Spritemap(graphic).add("fly", [0,1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,17,17,18,19,20,21,22,23,24,25,26,27], 30, true);
Spritemap(graphic).play("fly");
setHitbox(64, 64);
type = "bullet";
}
The collision is never detected but the animation plays fine. I’m doing something silly I’m sure, any ideas?