猫史档案馆


[求助]用常量存储的entity.player.facingDirection为什么会自动更新值?

用户:SCS_user_NeafwWelaeSCS_user_NeafwWelae查看:0 回复:1 评论:0 创建时间:2024-02-01T16:57:17


如题

const d = entity.player.facingDirection

定义常量d后 当玩家转向后 引用常量d是玩家当前的方向 而不是定义时的 
怎么解决?


回复

上一页1 页 / 共 1下一页
yh12i31yh12i31

代码换成:

const d = entity.player.facingDirection.clone();

不是很懂指针......

你问题的原因似乎是d和entity.player.facingDirection是同一个地址,entity.player.facingDirection变化d也会变化?

点赞0


评论