VISU - PHP Game Framework

DevEntityPicker
in package

Why is the prefixed "dev"? Because the way this picker works is by rendering available entities to a backbuffer and then reading the backbuffer to determine the entity ID. This is a very slow process and should only be used for debugging purposes, editor and nothing in direct gameplay.

Why not use a raycast? Because that would require us to generate bounding boxes or some form of collision detection for all entities which is difficult to say the least.

Table of Contents

Properties

$enabled  : bool
If enabled the picker will run on mouse click events
$delegate  : DevEntityPickerDelegate
$dispatcher  : Dispatcher
$entities  : EntityRegistry
$handleMouseClickId  : int
Function id for "handleMouseClick" handler
$renderTarget  : RenderTarget
$systems  : array<string|int, DevEntityPickerRenderInterface>
Array of systems that can produce pickable geometry

Methods

__construct()  : mixed
Constructor
__destruct()  : mixed
Destructor
handleMouseClick()  : void
Handles mouse click events
pickEntity()  : int
Picks an entity visible on screen and returns its ID

Properties

$enabled

If enabled the picker will run on mouse click events

public bool $enabled = false

$handleMouseClickId

Function id for "handleMouseClick" handler

private int $handleMouseClickId

Methods

pickEntity()

Picks an entity visible on screen and returns its ID

public static pickEntity(EntitiesInterface $entities, RenderTarget $renderTarget, CameraData $cameraData, array<string|int, DevEntityPickerRenderInterface$systems, int $x, int $y) : int
Parameters
$entities : EntitiesInterface
$renderTarget : RenderTarget
$cameraData : CameraData
$systems : array<string|int, DevEntityPickerRenderInterface>

Array of systems that can produce pickable geometry

$x : int

In screen coordinates not pixels

$y : int

In screen coordinates not pixels

Return values
int

        
On this page

Search results