persistent


描述

This variable can be read to find out if the instance is flagged as persistent or not, or it can used to set persistence to true (persistent) or false (not persistent) for the instance. A persistent instance is one that will be "carried over" from room to room, meaning (for example) that it only has to be created once at the start of the game and it will be present in all further rooms. Care should be taken with persistence as it is easy to lose track of persistent instances which can lead to problems later in the development of the game.

A persistent object will still have its Game Start, Game End, Room Start and Room End events triggered, however if you restart the game (with, for example, the game_restart() function) all persistent objects will be removed and only exist when created again by the game. 另请注意,如果你释放持久性物体,它将不会再从一个房间传递到另一个房间,除非在客户端事件触发之前重新启动。


语法:

persistent;


返回:

Boolean(布尔值)


例如:

if !persistent
   {
   persistent = true;
   }

The above code will check the instance to see if persistence is flagged as false and if the instance is NOT persistent the persistence flag is set to true.