Language

Map.createBullet


Map.createBullet(int depth, int x, int y, string texture, int frame_width, int frame_delay, bool custom_texture, int hitbox_offset_x, int hitbox_offset_y, int hitbox_width, int hitbox_height, float speedx, float speedy, int type)

Description

Add a bullet to the map.
For the hitbox parameters, refer to the image below:

Parameters

depth
The depth of the bullet. Between 0 and 20.
x
X coordinate.
y
Y coordinate.
texture
Name of the texture of the bullet.
frame_width
Width of one frame.
frame_delay
Delay in second of one frame.
custom_texture
Set to true if the texture is shipped with the maps (in the sprites sub-directory).
hitbox_offset_x
X offset of the hitbox of the bullet.
hitbox_offset_y
Y offset of the hitbox of the bullet.
hitbox_width
Width of the hitbox of the bullet.
hitbox_height
Height of the hitbox of the bullet.
speedx
Speed of the bullet in the X axis in pixels/seconds.
speedy
Speed of the bullet in the Y axis in pixels/seconds
type
0 = Player's bullet, 1 = Enemy bullet colliding with the world, 2 = Enemy bullet passing through everything.

Examples

Adding a bullet

  1. function onTrigger(name, state)
  2.     if name == "trap" then
  3.         -- Our bullet is made of two frames of 20px (so in a 40px image file)
  4.         Map.createAnimatedBullet(18, 50, 50, "boss_bullet.png", 20, 0.5, true, 5, 5, 10, 10, 0, 300, 2)
  5.     end
  6. end

See also

See Bullet