[Solved]Projectiles and stuff


Ok as advised in my last topic i’m splitting this up into only parts i need help with so i need help adding projectiles(bullets,bombs,etc). I already added the collision checks for them from the tutorial on the main site but i have no idea how to make the player and the enemy shoot and also im trying to implement bombs for to use for one the support npc’s but i couldn’t find anything on bombs.

(Martí Angelats i Ribera) #2

A projectile is a custom entity. Start making the entity with the collision handle. Add movement (usually a prefixed direction with a constant speed).

To add them just make it spawn every time a key goes down in the Player position looking and going to the same direction.

PS: If you are new in AS3 i highly recommend you to make some tutorials first.


I know but i couldn’t find any.

(Martí Angelats i Ribera) #4

Try searching “ActionScript 3 tutorial” in any search engine like Google. Literally millions of results will apear :wink:


Ok i tried that but i didn’t get a tutorial that actually taught what i needed it only showed some tutorials on angle calculation n stuff like that which i won’t need since the player will only be shooting straight ahead.

(Martí Angelats i Ribera) #6

Look tutorials for how to move a particle and particle collision. Just modifying the x and yvalue of an entity it moves.


Did that but there primarily particles for rain fire snow stars and all the background stuff. Like everything except bullets and bomb…do you know a specific tutorial the you used to learn how?


Ok after a really long search i found a good tutorial and got it. Here is some sample code if anyone else new has the same problem as me. package

	import net.flashpunk.Entity;
	import net.flashpunk.FP;
    import net.flashpunk.graphics.Spritemap;
	public class Bullet extends Entity
		[Embed(source = "../assets/bullet.png")]
		public static const BULLET:Class;
		private var sprites:Spritemap;
		private var moveX:Number = 0;
		private var moveY:Number = 0;
		public function Bullet()
			sprites = new Spritemap(BULLET, 10, 10);
			sprites.add("idle", [0, 1, 2], 12, true);
			graphic = sprites;
			setHitbox(10, 10);
			type = "bullet";
        public function setMovement(_x:Number = 0, _y:Number = 0):void
			moveX = _x;
			moveY = _y;
		override public function update():void
			x += moveX * FP.elapsed;
			y += moveY * FP.elapsed;
			if (x > FP.camera.x + FP.width + 50 || x < FP.camera.x - 50 || y < - 50 || y > FP.height + 50) {
		public function destroy():void