获取映射值


描述

With this action you can retrieve the value associated with a given key in a map data structure. You supply the variable that holds the map index (as returned by the action Create Map) and then give a "key" (which is the identifier within the map for a value), and also supply a target variable to hold the returned value (which can be flagged as a temporary local variable).

注意: If you give a key that does not exist in the map then the action will return undefined. You can check for this this using the If Undefined action.


动作语法:

Get Map Value Syntax


参数:

参数 描述
映射 The index (stored in a variable) of the map to get the value from
The key to get (real or string)
目标 The target variable to hold the returned map value


例如:

Get Map Value Example
The above action block code checks for a collision at the instance position and if one is found the unique ID of the colliding instance is stored in a temporary local variable.