draw_sprite_part_ext

Draws part of a sprite at a given position with scaling, blending and alpha options.

语法:

draw_sprite_part_ext(sprite, subimg, left, top, width, height, x, y, xscale, yscale, colour, alpha);


参数 描述
sprite The index of the sprite to draw.
subimg The subimg (frame) of the sprite to draw (image_index or -1 correlate to the current frame of animation in the object).
left The x position on the sprite of the top left corner of the area to draw.
top The y position on the sprite of the top left corner of the area to draw.
宽度 The width of the area to draw.
高度 The height of the area to draw.
x The x coordinate of where to draw the sprite.
y The y coordinate of where to draw the sprite.
x轴缩放 The horizontal scaling of the sprite, as a multiplier: 1 = normal scaling, 0.5 is half etc...
y轴缩放 The vertical scaling of the sprite, as a multiplier: 1 = normal scaling, 0.5 is half etc...
colour The colour with which to blend the sprite. c_white is to display it normally.
alpha The alpha of the sprite (from 0 to 1 where 0 is transparent and 1 opaque).


返回: N/A(无返回值)


描述

This function will draw a part of the chosen sprite at the given position following the same rules as per draw_sprite_part, only now you can scale the part, blend a colour with it, or change its alpha when drawing it to the screen (the same as when drawing a sprite with draw_sprite_ext). You should note that if the texture page permits automatic cropping then this function may not work as expected, since the extra "empty" space around the sprite will have been removed for creating the texture page. To resolve this issue, you will need to set the texture page settings (in the Texture Group Editor) to disable the Automatic Crop.

NOTE: When drawing with this function, the sprite x offset and y offset are ignored and the sprite part will be drawn with the top left corner at the specified x / y position in the room.
注意此函数只对 位图 精灵有用,并且对SWF或JSON(骨骼)精灵不起作用。
注意:启用WebGL时,建议仅为HTML5目标使用颜色混合,但如果未启用混合颜色,则仍可设置混合颜色,并且它将正常混合精灵。任何形式的混合会创建一个副本精灵储存在缓存,当需要时可供使用。如果你混合多种颜色,并且没有启用WebGL,将会降低你的游戏性能。如果你不希望使用WebGL,可以设置字体缓存大小以尝试使用函数 sprite_set_cache_size 来限制此值。


例如:

draw_sprite_part_ext(sprite_index, image_index, 8, 8, sprite_width-16, sprite_height-16, x, y, 2, 0.5, c_black, 1);

This will draw the instances assigned sprite (sprite_index) and its current frame of animation (image_index), however it will shave an 8px margin off all four sides of the sprite. It will then be stretched to double its usual width but half its usual height, and although the alpha is still 1, it will be blended with black (turning it into a silhouette).


上一页: Drawing Sprites And Tiles
下一页: draw_sprite_pos
© Copyright YoYo Games Ltd. 2018 All Rights Reserved