cocos / cocos-engine

Cocos simplifies game creation and distribution with Cocos Creator, a free, open-source, cross-platform game engine. Empowering millions of developers to create high-performance, engaging 2D/3D games and instant web entertainment.
https://www.cocos.com/en/creator
Other
5.49k stars 1.58k forks source link

[Tween System] Unlimited time update api #17207

Open smallmain opened 5 days ago

smallmain commented 5 days ago

Cocos Creator version

3.8.2

System information

MacOS

Issue description

Right now we have a finite time 'update' api. good job!

As discussed in the previous issue, this api gives users more freedom and is the basis for some speed-driven animations, hopefully soon.

tween()
    .update(
        (target: T, dt: number, ...args: R) => {
            const [speed] = args;
            target.string = String(Number(target.string) + speed);

            if (target.string === "100") {
                return false;
            }
        },
        ...args,
    )
    .start();

Details: https://github.com/cocos/cocos-engine/issues/17076

Relevant error log output

No response

Steps to reproduce

.

Minimal reproduction project

No response