sprite 您所在的位置:网站首页 img/sprite/Computer.png sprite

sprite

2024-07-16 17:50| 来源: 网络整理| 查看: 265

sprite_save Click here to see this page in full context sprite_save

This function can be used to save any sub-image of a sprite to disc, giving it the specified filename. The sprite must have been added at runtime (you cannot save sprites added through the IDE) and the file must be saved with聽a *.png extension.

NOTE聽Depending on the target platform that is chosen you are limited as to where you can save and load files from. See聽The File System聽for more information.

Syntax:

sprite_save(ind, subimg, fname);

Argument Type Description ind Sprite Asset The index of the sprite to save. subimg Real The sub-image of the sprite to save. fname String The filename for the saved sprite.

Returns

N/A

Example:

var surf, spr_custom; surf = surface_create(32, 32); surface_set_target(surf); draw_clear_alpha(c_black, 0); draw_sprite(spr_Body, 0, 0, 0); draw_sprite(spr_Clothes, 0, 0, 0); draw_sprite(spr_Hair, 0, 0, 0); spr_custom = sprite_create_from_surface(surf, 0, 0, 32, 32, true, true, 16, 16); surface_reset_target(); surface_free(surf); sprite_save(spr_custom, 0, "Player_Custom_Sprite.png"); sprite_delete(spr_Custom);

The above code creates a surface and stores its index in the local variable "surf". It then targets that surface, clears it and draws several sprites on top of each other. It creates a new sprite from the composite image drawn on the surface and assigns its index to the local variable "spr_Custom" before freeing up the memory used by the surface. Finally, the resulting sprite is saved to a file and then removed from memory too.

Back: Sprite Manipulation Next:聽sprite_save_strip 漏 Copyright YoYo Games Ltd. 2024 All Rights Reserved


【本文地址】

公司简介

联系我们

今日新闻

    推荐新闻

    专题文章
      CopyRight 2018-2019 实验室设备网 版权所有