egret-docs-master/Engine2D/event/priority/README.md

9 lines
453 B
Markdown
Raw Permalink Blame History

This file contains ambiguous Unicode characters!

This file contains ambiguous Unicode characters that may be confused with others in your current locale. If your use case is intentional and legitimate, you can safely ignore this warning. Use the Escape button to highlight these characters.

通过制定事件的优先级来设置事件侦听器的执行顺序。
可以在注册侦听器的时候制定事件的优先级。
```javascript
public addEventListener(type:string, listener:Function, thisObject:any, useCapture:boolean = false, priority:number = 0)
```
制定优先级需要设置 `priority` 属性。该属性为一个number类型当数字越大则优先级越大。在触发事件的时候优先级越高越先执行。