forked from 4ian/GDevelop
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathRenderedInstance.js
83 lines (73 loc) · 2.08 KB
/
RenderedInstance.js
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
73
74
75
76
77
78
79
80
81
82
83
/**
* RenderedInstance is the base class used for creating renderers of instances,
* which display on the scene editor, using Pixi.js, the instance of an object (see InstancesEditor).
*
* @class RenderedInstance
* @constructor
*/
function RenderedInstance(
project,
layout,
instance,
associatedObject,
pixiContainer,
pixiResourcesLoader
) {
this._pixiObject = null;
this._instance = instance;
this._associatedObject = associatedObject;
this._pixiContainer = pixiContainer;
this._project = project;
this._layout = layout;
this._pixiResourcesLoader = pixiResourcesLoader;
this.wasUsed = true; //Used by InstancesRenderer to track rendered instance that are not used anymore.
}
/**
* Convert an angle from degrees to radians.
*/
RenderedInstance.toRad = function(angleInDegrees) {
return (angleInDegrees / 180) * 3.14159;
};
/**
* Called when the scene editor is rendered.
*/
RenderedInstance.prototype.update = function() {
//Nothing to do.
};
RenderedInstance.prototype.getPixiObject = function() {
return this._pixiObject;
};
RenderedInstance.prototype.getInstance = function() {
return this._instance;
};
/**
* Called to notify the instance renderer that its associated instance was removed from
* the scene. The PIXI object should probably be removed from the container: This is what
* the default implementation of the method does.
*/
RenderedInstance.prototype.instanceRemovedFromScene = function() {
if (
this._pixiObject !== null &&
this._pixiContainer.children.indexOf(this._pixiObject) !== -1
)
this._pixiContainer.removeChild(this._pixiObject);
};
RenderedInstance.prototype.getOriginX = function() {
return 0;
};
RenderedInstance.prototype.getOriginY = function() {
return 0;
};
/**
* Return the width of the instance when the instance doesn't have a custom size.
*/
RenderedInstance.prototype.getDefaultWidth = function() {
return 32;
};
/**
* Return the height of the instance when the instance doesn't have a custom size.
*/
RenderedInstance.prototype.getDefaultHeight = function() {
return 32;
};
export default RenderedInstance;