Language

Map.createBullet


Map.createBullet(int depth, int x, int y, string texture, 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.
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.         Map.createBullet(18, 50, 50, "boss_bullet.png", true, 5, 5, 10, 10, 0, 300, 2)
  4.     end
  5. end