goplus / spx

spx - A Scratch Compatible Go/Go+ 2D Game Engine for STEM education
https://builder.goplus.org
Apache License 2.0
100 stars 28 forks source link

#builder#300 animation group issues #303

Closed JiepengTan closed 3 weeks ago

JiepengTan commented 1 month ago

issue: https://github.com/goplus/spx/issues/300 project file: bug_anim.zip config: image

result preview:

https://github.com/goplus/spx/assets/8347962/86e62662-ab2b-4a33-81e3-fae861cfa63e

nighca commented 1 month ago

@JiepengTan What is the relationship between these two:

  1. frameFrom, frameTo & frameFps
  2. from, to & fps

When should spx-user configure frameFrom, frameTo & frameFps, when shouldn't?

JiepengTan commented 1 month ago

@JiepengTan What is the relationship between these two:

  1. frameFrom, frameTo & frameFps
  2. from, to & fps

When should spx-user configure frameFrom, frameTo & frameFps, when shouldn't?

This design is for compatibility with old projects, although it is not very elegant.

Defination of "anitype": image

If you need the old behavior (only action, no animation playing), you do not need to configure frameFrom, frameTo , frameFps & anitype.

If configured, it will play an additional animation on top of the previous behavior: frameFrom: The frame where the animation starts frameTo: The frame where the animation ends frameFps: Animation playback speed (how many frames are played per second)

The purpose of fps is to adapt to: loop animations, such as step animations, fps can control the speed of animation playback.

JiepengTan commented 1 month ago

fixed : https://github.com/goplus/spx/issues/300

  1. The animation default (which is bound as defaultAnimation) is played only once while sprite in default state. It is expecetd to be played repeatedly (see details in https://github.com/goplus/builder/issues/603#issuecomment-2180367864)

  2. After animation fight (played by calling animate "fight") finished playing, the sprite does not return to the default state, while it keeps the last csotume of animation fight

https://github.com/user-attachments/assets/6ecd9c07-badf-4ebc-bb53-78f89e34e226

https://github.com/user-attachments/assets/b28027b3-a726-418e-a504-96453bf8edf7

@nighca

JiepengTan commented 1 month ago

@nighca nighca.zip

  1. frameFrom: The name of the starting image of the animation.
  2. frameTo: The name of the ending image of the animation.
  3. frameFps: The fps of the animation.

    1. turnToDuration: The duration of the turnTo action (the time for one circle, in seconds), default value is 1.(optional)
    2. stepDuration: The duration of the step action (the time for one step, in seconds), default value is 0.01.(optional)
    "fAnimations": {
        "fight": {
            "turnToDuration": 2,
            "frameFrom": "__animation_fight_attack_1-1",
            "frameTo": "__animation_fight_attack_1-4",
            "frameFps": 8
        },
        "dying": {
            "frameFrom": "__animation_dying_dead-1",
            "frameTo": "__animation_dying_dead-3",
            "frameFps": 8
        },
        "walk": {
            "stepDuration": 0.01,
            "frameFrom": "__animation_walk_walk-1",
            "frameTo": "__animation_walk_walk-8",
            "frameFps": 8
        },
        "default": { 
            "frameFrom": "__animation_default_idle-1",
            "frameTo": "__animation_default_idle-6",
            "frameFps": 16
        }
    },
nighca commented 4 weeks ago

@xushiwei Please review this PR; it’s an important fix for the Go+ Builder animation feature.