Deprecated: str_replace(): Passing null to parameter #1 ($search) of type array|string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 124

Deprecated: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in /var/www/vhosts/gamedevstudiogame.com/httpdocs/classes/client.php on line 124
Game dev studio

Classes

Concepts

Libraries

advertisement »

ambientSounds »

bitser »

contentPoints »

eventBoxText »

factValidity »

frameBuffer »

officeBuildingInserter »

priorityRenderer »

randomEvents »

scaling »

spritesheetParser »

statusIcons »

test3 »

util »

Objects

addFunctionReceiver

Description

Add an event handler that handles one event only. This is the most efficient way of handling events, since it means your code will have less branches in the event handling portion of it, resulting in greater overall performance, but it requires the most preparation.

Arguments

1 table handler

the event handling object.

2 function method

the function that will be handling the received event.

3 string event

the event to handle.

Example

local object = {}

function object:handleEventOne(event, data)
  print("this method handles eventOne!")
end

function object:handleEventTwo(event, data)
  print("this method handles eventTwo!")
end

events:addFunctionReceiver(object, object.handleEventOne, "eventOne")
events:addFunctionReceiver(object, object.handleEventTwo, "eventTwo")