Language

Player.isPositionIn


Player.isPositionIn(int x, int y, int width, int height) : boolean

Description

Test if the player's hitbox is in the given rectangle zone. You should take a look at triggers instead of this.

Parameters

x
The X position of the zone to test.
y
The Y position of the zone to test.
width
The width of the zone to test.
height
The height of the zone to test.

Return

Return true if the player is in the given zone. False otherwise.


Examples

Play a music when player goes in a specific location

THIS EXAMPLE IS DEPRECATED. THIS SHOULD USE TRIGGERS INSTEAD.

  1. local music = 0
  2.  
  3. function onReset()
  4.     music = 0
  5. end
  6.  
  7. function onUpdate(elapsed)
  8.     if Player.isPositionIn(221, 58, 13, 117) and music ~= 1 then
  9.         Sound.playMusic("DuckTales.ogg", true, 20)
  10.         music = 1
  11.     end
  12. end

Additional Notes

This function might be removed in the futur.