forked from playcanvas/engine
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsystem.js
More file actions
72 lines (58 loc) · 1.85 KB
/
system.js
File metadata and controls
72 lines (58 loc) · 1.85 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
import { Component } from '../component.js';
import { ComponentSystem } from '../system.js';
import { ButtonComponent } from './component.js';
import { ButtonComponentData } from './data.js';
const _schema = [
'enabled',
'active',
{ name: 'imageEntity', type: 'entity' },
{ name: 'hitPadding', type: 'vec4' },
'transitionMode',
{ name: 'hoverTint', type: 'rgba' },
{ name: 'pressedTint', type: 'rgba' },
{ name: 'inactiveTint', type: 'rgba' },
'fadeDuration',
'hoverSpriteAsset',
'hoverSpriteFrame',
'pressedSpriteAsset',
'pressedSpriteFrame',
'inactiveSpriteAsset',
'inactiveSpriteFrame'
];
/**
* @class
* @name ButtonComponentSystem
* @augments ComponentSystem
* @classdesc Manages creation of {@link ButtonComponent}s.
* @description Create a new ButtonComponentSystem.
* @param {Application} app - The application.
*/
class ButtonComponentSystem extends ComponentSystem {
constructor(app) {
super(app);
this.id = 'button';
this.ComponentType = ButtonComponent;
this.DataType = ButtonComponentData;
this.schema = _schema;
this.on('beforeremove', this._onRemoveComponent, this);
ComponentSystem.bind('update', this.onUpdate, this);
}
initializeComponentData(component, data, properties) {
super.initializeComponentData(component, data, _schema);
}
onUpdate(dt) {
var components = this.store;
for (var id in components) {
var entity = components[id].entity;
var component = entity.button;
if (component.enabled && entity.enabled) {
component.onUpdate();
}
}
}
_onRemoveComponent(entity, component) {
component.onRemove();
}
}
Component._buildAccessors(ButtonComponent.prototype, _schema);
export { ButtonComponentSystem };