gpt4 book ai didi

game-maker - 从其他实例对象访问自定义实例变量

转载 作者:行者123 更新时间:2023-12-03 22:19:11 25 4
gpt4 key购买 nike

我基本上有这个:

Obj1 创建事件:

health_total = 50;
health_current = health_total;
health_text = instance_create(x,y-10,obj_health); // Object to show health of an instance object

health_text.origin = self; // Assign an 'origin' variable so I can access it later?

obj_health 绘制事件:

show_debug_message(origin.x); // <-- This works just great!
show_debug_message(origin.health_current); // <-- This throws error :(

我假设该变量可能是本地变量,但我该如何将其公开? GML 对我来说有点新,但我对编程并不陌生。这让我很受伤。

最佳答案

使用id,而不是self:

health_text.origin = id;

关于game-maker - 从其他实例对象访问自定义实例变量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31572452/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com