The ComponentSystem that created this Component.
The Entity that this Component is attached to.
Private
_calculatedThe Entity with a ScreenComponent that this component belongs to. This is automatically set when the component is a child of a ScreenComponent.
Specifies where the left, bottom, right and top edges of the component are anchored relative to its parent. Each value ranges from 0 to 1. e.g. a value of [0, 0, 0, 0] means that the element will be anchored to the bottom left of its parent. A value of [1, 1, 1, 1] means it will be anchored to the top right. A split anchor is when the left-right or top-bottom pairs of the anchor are not equal. In that case the component will be resized to cover that entire area. e.g. a value of [0, 0, 1, 1] will make the component resize exactly as its parent.
Assign element to a specific batch group (see BatchGroup). Default is -1 (no group).
The distance from the bottom edge of the anchor. Can be used in combination with a split anchor to make the component's top edge always be 'top' units away from the top.
获得element4个角的世界坐标
The height at which the element will be rendered. In most cases this will be the same as
height
. However, in some cases the engine may calculate a different height for the element,
such as when the element is under the control of a LayoutGroupComponent. In these
scenarios, calculatedHeight
may be smaller or larger than the height that was set in the
editor.
The width at which the element will be rendered. In most cases this will be the same as
width
. However, in some cases the engine may calculate a different width for the element,
such as when the element is under the control of a LayoutGroupComponent. In these
scenarios, calculatedWidth
may be smaller or larger than the width that was set in the
editor.
An array of 4 Vec2s that represent the bottom left, bottom right, top right and top left corners of the component in canvas pixels. Only works for screen space element components.
The draw order of the component. A higher value means that the component will be rendered on top of other components.
Set how the content should be fitted and preserve the aspect ratio of the source texture or sprite. Only works for ELEMENTTYPE_IMAGE types. Can be:
The height of the element as set in the editor. Note that in some cases this may not reflect
the true height at which the element is rendered, such as when the element is under the
control of a LayoutGroupComponent. See calculatedHeight
in order to ensure you are
reading the true height at which the element will be rendered.
An array of layer IDs (Layer#id) to which this element should belong. Don't push, pop, splice or modify this array, if you want to change it - set a new one instead.
The distance from the left edge of the anchor. Can be used in combination with a split anchor to make the component's left edge always be 'left' units away from the left.
The distance from the left, bottom, right and top edges of the anchor. For example if we are using a split anchor like [0,0,1,1] and the margin is [0,0,0,0] then the component will be the same width and height as its parent.
Private
maskedPrivate
Get the entity that is currently masking this element.
The position of the pivot of the component relative to its anchor. Each value ranges from 0 to 1 where [0,0] is the bottom left and [1,1] is the top right.
The distance from the right edge of the anchor. Can be used in combination with a split anchor to make the component's right edge always be 'right' units away from the right.
An array of 4 Vec3s that represent the bottom left, bottom right, top right and top left corners of the component relative to its parent ScreenComponent.
The height of the text rendered by the component. Only works for ELEMENTTYPE_TEXT types.
The width of the text rendered by the component. Only works for ELEMENTTYPE_TEXT types.
The distance from the top edge of the anchor. Can be used in combination with a split anchor to make the component's bottom edge always be 'bottom' units away from the bottom.
The type of the ElementComponent. Can be:
If true then the component will receive Mouse or Touch input events.
The width of the element as set in the editor. Note that in some cases this may not reflect
the true width at which the element is rendered, such as when the element is under the
control of a LayoutGroupComponent. See calculatedWidth
in order to ensure you are
reading the true width at which the element will be rendered.
An array of 4 Vec3s that represent the bottom left, bottom right, top right and top left corners of the component in world space. Only works for 3D element components.
Fired when a touch is canceled on the component. Only fired when useInput is true.
ElementComponent#touchcancel
Fire an event, all additional arguments are passed on to the event listener.
Self for chaining.
obj.fire('test', 'This is the message');
Name of event to fire.
Optional
arg1: anyFirst argument that is passed to the event handler.
Optional
arg2: anySecond argument that is passed to the event handler.
Optional
arg3: anyThird argument that is passed to the event handler.
Optional
arg4: anyFourth argument that is passed to the event handler.
Optional
arg5: anyFifth argument that is passed to the event handler.
Optional
arg6: anySixth argument that is passed to the event handler.
Optional
arg7: anySeventh argument that is passed to the event handler.
Optional
arg8: anyEighth argument that is passed to the event handler.
根据屏幕位置获得element的像素值
element在此屏幕坐标的像素值
屏幕坐标
Optional
camera: CameraComponentOptional
color: Color颜色值(不传则创建新的颜色)
Test if there are any handlers bound to an event name.
True if the object has handlers bound to the specified event name.
obj.on('test', function () { }); // bind an event to 'test'
obj.hasEvent('test'); // returns true
obj.hasEvent('hello'); // returns false
The name of the event to test.
Detach an event handler from an event. If callback is not provided then all callbacks are unbound from the event, if scope is not provided then all events with the callback will be unbound.
Self for chaining.
var handler = function () {
};
obj.on('test', handler);
obj.off(); // Removes all events
obj.off('test'); // Removes all events called 'test'
obj.off('test', handler); // Removes all handler functions, called 'test'
obj.off('test', handler, this); // Removes all handler functions, called 'test' with scope this
Optional
name: stringName of the event to unbind.
Optional
callback: HandleEventCallbackFunction to be unbound.
Optional
scope: objectScope that was used as the this when the event is fired.
Attach an event handler to an event.
Self for chaining.
obj.on('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: objectObject to use as 'this' when the event is fired, defaults to current this.
Attach an event handler to an event. This handler will be removed after being fired once.
Self for chaining.
obj.once('test', function (a, b) {
console.log(a + b);
});
obj.fire('test', 1, 2); // prints 3 to the console
obj.fire('test', 1, 2); // not going to get handled
Name of the event to bind the callback to.
Function that is called when event is fired. Note the callback is limited to 8 arguments.
Optional
scope: objectObject to use as 'this' when the event is fired, defaults to current this.
Static
_build
Create a new ElementComponent instance.