Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

快速上手:制作第一个游戏 #1800

Closed
drelaptop opened this issue Sep 10, 2021 · 8 comments
Closed

快速上手:制作第一个游戏 #1800

drelaptop opened this issue Sep 10, 2021 · 8 comments

Comments

@drelaptop
Copy link

drelaptop commented Sep 10, 2021

URL : https://github.com/cocos-creator/creator-docs/blob/master/zh/getting-started/first-game/index.md

首先需要在 PlayerController 组件中引用 Body 身上的 Animation。

 @property({type: Animation})
 public BodyAnim: Animation | null = null;

文档和api都过时了?!!这样写无法绑定组件,要改成这样:

    @property(AnimationComponent)
    public BodyAnim: AnimationComponent = null; 
@xunyi0
Copy link
Contributor

xunyi0 commented Sep 13, 2021

你好,我这里验证是正常的,请问你文档跟编辑器的版本有对应吗?具体的操作步骤是怎样的呢?有报错信息吗?

@drelaptop
Copy link
Author

对应的,是3.3.0。并且看了“cocos store”幽灵射手的源码,里面对动画组件的引用,用的也是 AnimationComponent ,并没有用 Animation。

@xunyi0
Copy link
Contributor

xunyi0 commented Sep 16, 2021

在这个 issue 里面有说明了,旧版本是用的 AnimationComponent,后面改名为 Animation 了,但之前的 AnimationComponent 也是兼容的。麻烦检查一下是否有报错信息之类的呢

@ljybill
Copy link

ljybill commented Oct 12, 2021

在这个 issue 里面有说明了,旧版本是用的 AnimationComponent,后面改名为 Animation 了,但之前的 AnimationComponent 也是兼容的。麻烦检查一下是否有报错信息之类的呢

我也遇到这个问题了,解决方案和楼主一样。我以为Animation是旧版本的。具体表现为我设置了Animation后,cocosCreator上无法绑定组件,改成AnimationComponent就可以了。

另外我刚才修改了下代码,发现无法复现了。我觉得开发者可以新建一个项目跟着教程步骤来一遍试试

@drelaptop
Copy link
Author

@ljybill @xunyi0 可能和这个导出定义有关系?后来新建项目,不导出定义,也没报错,可以正常用。
image

@xunyi0
Copy link
Contributor

xunyi0 commented Oct 28, 2021

3.x 是默认会有代码提示的,项目升级也是会自动更新的,只有自定义了引擎才需要手动操作更新。
Export.d.ts 是写插件的时候用来参考使用的,比如 这篇文档 里面介绍的

@drelaptop
Copy link
Author

了解,之前就按照2.x的经验,直接点了导出。thanks!

@risu-p
Copy link

risu-p commented Jul 24, 2023

3.7 改为AnimationComponent才正常

若使用Animation,此处显示 Null,无法进行教程中的下一步:
image
教程中的步骤:
image

并且Animationplay()方法,无法接受参数:
image
改为AnimationComponent后一切正常

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants