mirror of
https://github.com/Heretek-AI/GDevelop.git
synced 2026-08-25 12:23:58 -04:00
Add an action to change the tileset texture
This commit is contained in:
@@ -41,6 +41,7 @@
|
||||
<resources>
|
||||
<resources>
|
||||
<resource alwaysLoaded="false" file="tiles_spritesheet.png" kind="image" name="tiles_spritesheet.png" smoothed="true" userAdded="true" />
|
||||
<resource alwaysLoaded="false" file="../../../../n.png" kind="image" name="n.png" smoothed="true" userAdded="true" />
|
||||
</resources>
|
||||
<resourceFolders />
|
||||
</resources>
|
||||
|
||||
@@ -167,6 +167,21 @@ void DeclareTileMapObjectExtension(gd::PlatformExtension & extension)
|
||||
.MarkAsSimple()
|
||||
.codeExtraInformation.SetFunctionName("LoadFromString").SetIncludeFile("TileMapObject/RuntimeTileMapObject.h");
|
||||
|
||||
|
||||
|
||||
obj.AddAction("ChangeTexture",
|
||||
_("Change the tileset texture"),
|
||||
_("Change the tileset texture."),
|
||||
_("Change the tileset texture of _PARAM0_ to _PARAM1_"),
|
||||
_("Tileset"),
|
||||
"CppPlatform/Extensions/TileMapIcon24.png",
|
||||
"res/TileMapIcon16.png")
|
||||
.AddParameter("objectList", _("Tile Map Object"), "TileMap", false)
|
||||
.AddParameter("string", _("The new texture name"))
|
||||
.AddCodeOnlyParameter("currentScene", "")
|
||||
.MarkAsSimple()
|
||||
.codeExtraInformation.SetFunctionName("ChangeTexture").SetIncludeFile("TileMapObject/RuntimeTileMapObject.h");
|
||||
|
||||
#endif
|
||||
}
|
||||
|
||||
|
||||
@@ -217,6 +217,14 @@ void RuntimeTileMapObject::LoadFromString(const std::string &str)
|
||||
needGeneration = true;
|
||||
}
|
||||
|
||||
void RuntimeTileMapObject::ChangeTexture(const std::string &textureName, RuntimeScene &scene)
|
||||
{
|
||||
tileSet.Get().textureName = textureName;
|
||||
tileSet.Get().LoadResources(*(scene.game));
|
||||
tileSet.Get().Generate();
|
||||
needGeneration = true;
|
||||
}
|
||||
|
||||
namespace
|
||||
{
|
||||
/**
|
||||
|
||||
@@ -93,6 +93,8 @@ public :
|
||||
std::string SaveAsString() const;
|
||||
void LoadFromString(const std::string &str);
|
||||
|
||||
void ChangeTexture(const std::string &textureName, RuntimeScene &scene);
|
||||
|
||||
TileSetProxy tileSet;
|
||||
TileMapProxy tileMap;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user