Free ActionScript

Flash AS2 & AS3 Tutorials, Game Code, Effects, Source Files & Sample Downloads

Laser Weapon (with wall collision detection)

This is an AS3 update to my old AS2 laser script with a few improvements:

  • You can now easily check if the laser is hitting multiple walls by adding movieclips to an array
  • I also added a delayed turret rotation – this way the turret doesn’t feel “glued” to the mouse
  • Optimized and cleaned up the code

You can set the following weapon settings:

  • turret rotation speed – how fast turret rotates towards mouse. default is 20
  • barrel length – how far from turret laser starts drawing. default is 15
  • laser range – default is 100
  • laser color – default is green #00FF00
  • laser width – default is 2
  • laser blur strength – default is 2

Preview

Download Fla Sample

Download Fla Sample

Laser Hitting Solid Objects & Walls

As the title suggests, this is a laser weapon script that shoots a laser beam. The beam stops when it hits solid objects. Written in AS2 to be used in Flash shooter games.

Download Fla Sample

Download Fla Sample

If you’re having trouble understanding how this script works, please review previously posted examples that were incorporated in to this script: Shooting Laser Weapon & Apply Filters Dynamically.

Update:
ActionScript 3 version of this script is available here:

http://www.freeactionscript.com/2011/07/laser-weapon-with-wall-collision-detection/

Weapon – Shooting Laser

This script shows you how to shoot a laser weapon from the player movieclip towards the mouse x & y position.

Game Engine – Shooting Laser Weapon

Download Fla Sample

Download Fla Sample

Customizable Game Weapon Settings:

  • reload speed
  • laser offset
  • laser width
  • laser color
  • laser alpha

Read the rest of this entry »