家人们,问个刷新节点动画闪烁问题

UI角色通过bundle加载动画,现在刷新,需要先destroy,然后再重新加载新角色动画。这样就会闪烁,家人们碰到这种情况是怎么解决闪烁问题的?

用渐显动画?

加载完成回调了 再替换呗

用过,效果不好

貌似可以,只是每个角色不只是纹理不一样,动画也不一样。比如有个角色有5个动画,有的只有3个或4个。

那应该不行,理论上你都销毁节点了。就只能从刷新的动画过渡找补了吧。不然你能提前创建新的角色,然后新角色创建好,才销毁旧角色节点呢。

没太明白你说的意思,我现在是用的AI提供的方案:
// 角色商品 - 使用双容器切换
const container1 = item.getChildByName(‘node_role_1’);
const container2 = item.getChildByName(‘node_role_2’);

        // 设置容器可见
        container1.active = true;
        container2.active = true;

        // 为这个 item 存储当前激活的容器索引
        if (!item['_activeContainerIndex']) {
            item['_activeContainerIndex'] = 0;
        }

        const activeIndex = item['_activeContainerIndex'];
        const currentContainer = activeIndex === 0 ? container1 : container2;
        const nextContainer = activeIndex === 0 ? container2 : container1;

        // 清除后台容器并加载新角色
        nextContainer.destroyAllChildren();

        UIUtils.createRole(nextContainer, data.roleID, GroupType.Self, () => {
            // 切换显示
            currentContainer.active = false;
            nextContainer.active = true;

            // 更新索引
            item['_activeContainerIndex'] = activeIndex === 0 ? 1 : 0;

            // 清理旧容器
            currentContainer.destroyAllChildren();
        });

        item.getChildByName('img_asset').active = false;
        item.getChildByName('lab_num').getComponent(Label).string = 'x' + data.num;
        item.getChildByName('btn_free').active = false;
        item.getChildByName('btn_buy').active = !data.isSold;
        item.getChildByName('lab_sell_out').active = data.isSold;
        item.getChildByPath('btn_buy/Label').getComponent(Label).string = data.price + '';
        item.getChildByName('btn_buy').off(Button.EventType.CLICK);
        item.getChildByName('btn_buy').on(Button.EventType.CLICK, () => {
            const haveCoin = PlayerInfo.instance.getCoinNum();
            if (haveCoin < data.price) {
                UIUtils.alert('金币不足');
                return;
            }
            PlayerInfo.instance.addRole(data.roleID, data.num);
            PlayerInfo.instance.addCoin(-data.price);
            EventDispatch.instance.emit(EventName.GetRole, nextContainer.children[0]);
            StoreInfo.instance.purchaseItem(index);
            this.shopList.reloadWithIndex(index);
        })

这是你的逻辑问题,跟闪烁没关系,如果上述提到的方案可行的话,就是你需要等资源加载好再去替换,你先destory的话,资源没加载好,这中间的空白期就是闪烁的原因。

嗯,确实。改成加载好再destroy了