| 123456789101112131415161718192021222324252627282930313233343536373839 |
- /// @desc 优雅地在给定深度与位置创建某个实例
- /// @param {Asset.GMObject} _obj 将要创建的实例
- /// @param {real} _x x坐标,默认为创建者的x坐标
- /// @param {real} _y y坐标,默认为创建者的y坐标
- /// @param {real} _depth 深度,默认为0
- function icd(_obj, _x = x, _y = y, _depth = 0)
- {
- return instance_create_depth(_x, _y, _depth, _obj);
- }
- /// @desc 优雅地在给定层级与位置创建某个实例
- /// @param {Asset.GMObject} _obj 将要创建的实例
- /// @param {real} _x x坐标,默认为创建者的x坐标
- /// @param {real} _y y坐标,默认为创建者的y坐标
- /// @param {string} _layer_id 层级,默认为"Instances"
- function icl(_obj, _x = x, _y = y, _layer_id = "Instances")
- {
- return instance_create_layer(_x, _y, _layer_id, _obj);
- }
- /// @desc 内部辅助函数,自动检测字符类型并映射为整数(不要在外部直接调用)
- /// @param {Constant.VirtualKey|Real} _key 需要转义的字符
- function key_get_id(_key) {
- return is_string(_key) ? ord(_key) : _key;
- }
- /// @desc 优雅地检测此帧某给定键盘按键是否被按住
- /// @param {Constant.VirtualKey|Real} _key 检测的键盘按键
- function kc(_key)
- {
- return keyboard_check(key_get_id(_key));
- }
- /// @desc 优雅地检测此帧某给定键盘按键是否被按下
- /// @param {Constant.VirtualKey|Real} _key 检测的键盘按键
- function kcp(_key) {
- return keyboard_check_pressed(key_get_id(_key));
- }
- /// @desc 优雅地检测此帧某给定键盘按键是否被松开
- /// @param {Constant.VirtualKey|Real} _key 检测的键盘按键
- function kcr(_key) {
- return keyboard_check_released(key_get_id(_key));
- }
|