0-2D节点,1-3D节点,2-New UI节点
Under the premise that this object is non-penetrable (mouseThrough is false), specify whether the mouse event capture detection prioritizes this object. When set to true, the object itself is prioritized for detection. When set to false, the child objects are prioritized. When set to prioritize the object itself, the object is detected first. If the object itself is not hit, the detection is directly interrupted, indicating that no target was hit. If the object itself is hit, further recursive detection is performed on its child objects until the final mouse hit target is found or all child nodes have been checked. When set to prioritize child objects, the child objects are recursively detected first. If a child object is hit, the detection is interrupted and the hit target is obtained. If all child nodes have been checked and no child object is hit, then the detection checks if the object itself is hit. In most cases, prioritizing the detection of child objects is advisable unless the developer does not care about the mouse event detection results of the current node's child nodes. For example, when child nodes are certainly within the width and height range of the parent node's container, there is no need for recursive detection layer by layer if the mouse click does not occur within the parent node's area. Using this property appropriately can reduce the nodes for mouse event detection and improve performance.
在本对象为不可穿透(mouseThrough为false)的前提下,指定鼠标事件捕获检测是否优先检测本对象。为true
时优先检测本对象,为false
时优先检测子对象。
优先检测本对象时,如果本对象没有被检测命中,会中断检测,表示没有命中目标;如果本对象被检测命中,则进一步递归检测其子对象,直到找到鼠标最终的命中目标或所有子节点都检测完毕。
优先检测子对象时,先递归检测其子对象,如果子对象被检测命中,则中断检测,获得命中目标。如果所有子节点都检测完毕,仍未检测命中任何子对象,最后再检测本对象是否被命中;
大多数情况下需要优先检测子对象,除非开发者并不关心当前节点的子节点的鼠标事件检测结果,也就是以当前节点作为其子节点的鼠标事件检测依据。例如,子节点肯定在父节点的容器宽高范围内,当鼠标点击不发生在父节点范围内的区域时,就不必层层递归检测了。
合理使用本属性,能减少鼠标事件检测的节点,提高性能。
For non-UI component display object nodes (container objects or display objects without image resources), specifies whether the mouse events penetrate this object's collision detection. true
means the object is penetrable, false
means it is not penetrable.
When penetrable, the engine will no longer detect this object and will recursively check its child objects until it finds the target object or misses all objects.
When not penetrable, the node's width and height define the mouse collision area (a non-penetrable rectangular area). If the rectangular collision area does not meet the requirements, you can use the drawing area of the hit area as the collision area. The hit area takes precedence over width and height of node as the non-penetrable mouse collision area.
Note that for UI object nodes with a set skin property, once a skin texture resource is set, this property becomes ineffective, and the rectangular area drawn by the texture will always be non-penetrable unless it does not accept mouse events or a non-clickable area is set.
True if the height is set, otherwise false.
True if the width is set, otherwise false.
Animation types with their descriptions.
Whether to automatically calculate the width and height of the node. The default value is false
, which does not automatically calculate and offers better performance.
If you want to get the width and height based on the drawn content, you can set this property to true
, or use the getBounds method to obtain them, which has some impact on performance.
Specifies whether the display object is cached as a static image. When cacheAs is set, changes in child objects will automatically update the cache. You can also manually call the reCache method to update the cache. It is recommended to cache "complex content" that does not change frequently as a static image to greatly improve rendering performance. The default is "none," which does not perform any caching. When set to "bitmap," renderTarget caching is used. Disadvantages of the renderTarget caching mode: it creates additional renderTarget objects, increasing memory overhead, has a maximum cache area limit of 2048, and can increase CPU overhead with constant redrawing. Advantages: it significantly reduces draw calls and provides the highest rendering performance.
The display height.
The display width.
The drag support object (DragSupport).
Automatically optimize DrawCall. When enabled, all rendering elements contained in the children and grandchildren of this node will be merged into as few DrawCalls as possible without affecting the actual display effect, such as images from the same texture atlas or text. They will be adjusted to a continuous rendering order so that they can be merged into the same DrawCall.
Note that if the number of elements is large (e.g., greater than 500), it may significantly consume CPU performance. Developers need to balance the number of DrawCalls and CPU performance consumption.
The global X-axis scale.
The global Y-axis scale.
You can set a rectangular area as the clickable region, or set a HitArea instance as the clickable region. The HitArea can have both clickable and non-clickable areas defined. If the hitArea is not set, the mouse collision detection will be based on the area formed by the width and height of the object.
The scroll rectangle range of the display object, with a clipping effect (if you only want to limit the rendering area of child objects, please use viewport). Differences between srollRect and viewport:
动态参数
...args: Node[]A variable number of child nodes to be added.
The specified node.
A Boolean value indicating whether the current node contains the specified node.
The width of the canvas.
The height of the canvas.
The X-axis offset for drawing.
The Y-axis offset for drawing.
The HTMLCanvas object.
The width of the canvas.
The height of the canvas.
The X-axis offset for drawing.
The Y-axis offset for drawing.
可选
rt: RenderTexture2DThe render target.
可选
isDrawRenderRect: booleanA boolean indicating whether to draw the render rectangle. When true, it starts drawing from (0,0) of the render texture and subtracts the offset of the cache rectangle. When false, it keeps the sprite's original relative position for drawing.
可选
flipY: booleanOptional. If true, the texture will be flipped vertical. Default is false.
可选
clearColor: ColorOptional. If provided, the texture will be cleared to this color before drawing. Default is null.
可选。渲染缩放 X。默认为 1。
可选。渲染缩放 Y。默认为 1。
The drawn RenderTexture2D object.
The width of the canvas.
The height of the canvas.
The X-axis offset for drawing.
The Y-axis offset for drawing.
The render target.
A boolean indicating whether to draw the render rectangle. When true, it starts drawing from (0,0) of the render texture and subtracts the offset of the cache rectangle. When false, it keeps the sprite's original relative position for drawing.
The drawn Texture or RenderTexture2D object.
The type of event.
可选
data: any(Optional) Data to pass to the callback. If multiple parameters p1, p2, p3, ... need to be passed, use an array structure such as [p1, p2, p3, ...]. If a single parameter p needs to be passed and p is an array, use a structure such as [p]. For other single parameters p, you can directly pass parameter p. If data is Event.EMPTY, it means passing an Event object to the callback function. Note that it is not passing Event.TEMP, but an independent Event object.
True if there are listeners for this event type, false otherwise.
The interval between executions, in frames.
The execution scope of the callback function (this).
The callback function.
The parameters passed to the callback function.
Whether to override the previous delayed execution. The default value is true.
The delay time, in frames.
The execution scope of the callback function (this).
The callback function.
The parameters passed to the callback function.
Whether to override the previous delayed execution. The default value is true.
The child node to query.
The index of the child node.
The global coordinate point.
可选
createNewPoint: boolean(Optional) Whether to create a new Point object as the return value. The default is false, which uses the input point object as the return value to reduce object creation overhead.
可选
globalNode: SpriteThe global node, default is Laya.stage.
The converted local coordinate point.
The node to check.
True if this node is an ancestor of the given node, false otherwise.
The path of the animation file to load.
可选
complete: HandlerThe callback function when the loading is complete.
The path of the animation file to load.
可选
complete: (() => void)The callback function when the loading is complete.
The image URL.
可选
complete: Handler(Optional) The callback function when loading is complete.
Returns the Sprite object itself.
The local coordinate point.
可选
createNewPoint: boolean(Optional) Whether to create a new Point object as the return value. The default is false, which uses the input point object as the return value to reduce object creation overhead.
可选
globalNode: SpriteThe global node, default is Laya.stage.
The converted global coordinate point.
The type of event.
The listener function.
This EventDispatcher object.
The type of event.
The execution scope of the event listener function.
可选
listener: FunctionThe listener function.
可选
args: any[]This EventDispatcher object.
可选
type: string(Optional) The type of event. If the value is null, all types of listeners on this object are removed.
This EventDispatcher object.
The target caller object.
This EventDispatcher object.
The type of event.
The listener function.
This EventDispatcher object.
The type of event.
The execution scope of the event listener function.
The listener function.
可选
args: any[](Optional) The callback parameters of the event listener function.
This EventDispatcher object.
The type of event.
The listener function.
This EventDispatcher object.
The type of event.
The execution scope of the event listener function.
The listener function.
可选
args: any[](Optional) The callback parameters of the event listener function.
This EventDispatcher object.
The name or index of the animation to play.
Whether to loop the animation.
If false, the animation will not take effect if the same one is already playing. If true, it will force the animation to play.
The start time of the animation.
The end time of the animation.
Whether to refresh the skin data.
Whether to play the animation's audio.
可选
beginIndex: numberThe begin index.
可选
endIndex: numberThe end index.
可选
destroy: booleanWhether to destroy the child nodes. If true, all child nodes will be destroyed; otherwise, they will only be removed from the parent.
The node itself.
The Graphics object to set.
可选
transferOwnership: booleanWhether to set the Graphics object to the belonging node (i.e., transfer the ownership of the Graphics object to the Sprite). If true, the Sprite will be responsible for destroying the Graphics object when it's no longer needed.
The bounds rectangle.
The name of the slot.
The custom texture to be applied.
可选
area: Rectangle(Optional) The drag area, which is the active area of the object's registration point (excluding the object's width and height).
可选
hasInertia: boolean(Optional) Whether the object has inertia when the mouse is released. The default is false.
可选
elasticDistance: number(Optional) The distance value of the elastic effect. A value of 0 means no elastic effect. The default is 0.
可选
elasticBackTime: number(Optional) The bounce-back time for the elastic effect in milliseconds. The default is 300 milliseconds.
可选
data: any(Optional) The data carried by the drag event.
可选
ratio: number(Optional) The inertia damping coefficient, which affects the strength and duration of inertia.
The interval between executions, in milliseconds.
The execution scope of the callback function (this).
The callback function.
The parameters passed to the callback function.
Whether to override the previous delayed execution. The default value is true.
Whether the callback should be executed when the timer jumps frames. The default value is false. If set to true, the callback will be executed multiple times in a single frame if possible, for performance reasons.
The delay time, in milliseconds.
The execution scope of the callback function (this).
The callback function.
The parameters passed to the callback function.
Whether to override the previous delayed execution. The default value is true.
静态
drawThe Sprite to draw.
The width of the canvas.
The height of the canvas.
The X-axis offset for drawing.
The Y-axis offset for drawing.
可选
rt: RenderTexture2DThe render target. If not provided, a new RenderTexture2D will be created.
可选
isDrawRenderRect: booleanA boolean indicating whether to draw the render rectangle. When true, it starts drawing from (0,0) of the render texture and subtracts the offset of the cache rectangle. When false, it keeps the sprite's original relative position for drawing.
可选
flipY: booleanOptional. If true, the texture will be flipped vertical. Default is false.
可选
clearColor: ColorOptional. If provided, the texture will be cleared to this color before drawing. Default is null.
Optional. The scale of the render texture. Default is 1.
Optional. The scale of the render texture. Default is 1.
The drawn RenderTexture2D object.
静态
from
En
Skeleton animation consists of three parts: Template, AnimationPlayer, and Skeleton.
Zh
骨骼动画由Templet,AnimationPlayer,Skeleton三部分组成。