更新
This commit is contained in:
1 parent
5cd551a08e
commit
40cde540d6
33 files changed
+547
-319
No files matched your search
@@ -1,13 +1,16 @@
|
||||
---
|
||||
title: egret粒子系统官方文档的那些坑
|
||||
tags: []
|
||||
id: '200'
|
||||
categories:
|
||||
- - 分享
|
||||
- 分享
|
||||
tags:
|
||||
- egret
|
||||
- 粒子系统
|
||||
- RES
|
||||
date: 2017-10-20 16:33:15
|
||||
---
|
||||
|
||||
最近体验了一下[egret粒子系统](http://edn.egret.com/cn/article/index/id/178),看了官方文档后,照着文档写,发现各种报错,不知道是原来文档就是错误的,还是egret版本多次迭代后,文档没有及时更新,而且在[egret开发者中心](http://developer.egret.com/)提供的QQ群加了也没有回应,或许是egret官方太忙了,但是不管怎样,这种错误的官方文档对新手很不友好。
|
||||
最近体验了一下[egret粒子系统](http://edn.egret.com/cn/article/index/id/178), 看了官方文档后,照着文档写,发现各种报错,不知道是原来文档就是错误的,还是egret版本多次迭代后,文档没有及时更新,而且在[egret开发者中心](http://developer.egret.com/)提供的QQ群加了也没有回应,或许是egret官方太忙了,但是不管怎样,这种错误的官方文档对新手很不友好。
|
||||
|
||||
下面我来说说我在体验[egret粒子系统](http://edn.egret.com/cn/article/index/id/178)踩的一些坑
|
||||
|
||||
@@ -23,13 +26,15 @@ date: 2017-10-20 16:33:15
|
||||
|
||||
按照示例的代码在egret 4.0.3版本中,编译就会报错
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
error TS2339: Property 'system' does not exist on type 'Main'.
|
||||
```
|
||||
|
||||
'system'这个属性不属于'Main',新人们在这里会懵逼一会儿,但是代码是死的,人是活的,我直接用个变量来保存particle对象嘛。我把代码改一下
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
let texture = RES.getRes("funny");
|
||||
let config = RES.getRes("funny_json");
|
||||
let funny = new particle.GravityParticleSystem(texture, config);
|
||||
@@ -39,20 +44,23 @@ error TS2339: Property 'system' does not exist on type 'Main'.
|
||||
|
||||
我用个变量funny来保存particle对象,然后我再编译一下,没有报错,但是刷新浏览器的时候报错了
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
Uncaught TypeError: Cannot read property 'textureWidth' of null
|
||||
```
|
||||
|
||||
无法读取纹理的宽度,其值为null。出现这种报错一般就是纹理加载不成功,所以要看看加载素材的地方
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
let texture = RES.getRes("funny");
|
||||
let config = RES.getRes("funny_json");
|
||||
```
|
||||
|
||||
上面的纹理加载很明显与egret的素材加载方式有点不一样,不知道官方文档为什么会这样写,所以我改了一下,把纹理的后缀加上
|
||||
|
||||
```
|
||||
```
|
||||
|
||||
let texture = RES.getRes("funny_png");
|
||||
let config = RES.getRes("funny_json");
|
||||
```
|
||||
@@ -71,4 +79,4 @@ egret粒子系统库的引入也是一个小坑,我从[egret第三方库的Git
|
||||
|
||||
**第三方库必须放到项目外面!**
|
||||
|
||||
重要的事情说三遍
|
||||
重要的事情说三遍
|
||||
Reference in new issue
Block a user