Skip to content

New extension: Dynamic tiled sprite changer #1139

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
95 changes: 95 additions & 0 deletions extensions/community/DynamicTiledSpriteChanger.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,95 @@
{
"author": "",
"category": "Advanced",
"extensionNamespace": "",
"fullName": "Change TiledSprite Dynamic",
"helpPath": "",
"iconUrl": "data:image/svg+xml;base64,PD94bWwgdmVyc2lvbj0iMS4wIiBlbmNvZGluZz0idXRmLTgiPz4NCjwhLS0gR2VuZXJhdG9yOiBBZG9iZSBJbGx1c3RyYXRvciAyMy4wLjMsIFNWRyBFeHBvcnQgUGx1Zy1JbiAuIFNWRyBWZXJzaW9uOiA2LjAwIEJ1aWxkIDApICAtLT4NCjxzdmcgdmVyc2lvbj0iMS4xIiBpZD0iSWNvbnMiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgeG1sbnM6eGxpbms9Imh0dHA6Ly93d3cudzMub3JnLzE5OTkveGxpbmsiIHg9IjBweCIgeT0iMHB4Ig0KCSB2aWV3Qm94PSIwIDAgMzIgMzIiIHN0eWxlPSJlbmFibGUtYmFja2dyb3VuZDpuZXcgMCAwIDMyIDMyOyIgeG1sOnNwYWNlPSJwcmVzZXJ2ZSI+DQo8c3R5bGUgdHlwZT0idGV4dC9jc3MiPg0KCS5zdDB7ZmlsbDpub25lO3N0cm9rZTojMDAwMDAwO3N0cm9rZS13aWR0aDoyO3N0cm9rZS1saW5lY2FwOnJvdW5kO3N0cm9rZS1saW5lam9pbjpyb3VuZDtzdHJva2UtbWl0ZXJsaW1pdDoxMDt9DQoJLnN0MXtmaWxsOm5vbmU7c3Ryb2tlOiMwMDAwMDA7c3Ryb2tlLXdpZHRoOjI7c3Ryb2tlLWxpbmVqb2luOnJvdW5kO3N0cm9rZS1taXRlcmxpbWl0OjEwO30NCjwvc3R5bGU+DQo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMjMuMSw1TDIyLDNoLTNjLTEuMSwwLTIsMC45LTIsMnYwdjN2M2MwLDEuMSwwLjksMiwyLDJoOGMxLjEsMCwyLTAuOSwyLTJWN2MwLTEuMS0wLjktMi0yLTJIMjMuMXoiLz4NCjxwYXRoIGNsYXNzPSJzdDAiIGQ9Ik05LjEsMjFMOCwxOUg1Yy0xLjEsMC0yLDAuOS0yLDJ2MHYzdjNjMCwxLjEsMC45LDIsMiwyaDhjMS4xLDAsMi0wLjksMi0ydi00YzAtMS4xLTAuOS0yLTItMkg5LjF6Ii8+DQo8cGF0aCBjbGFzcz0ic3QwIiBkPSJNMTYsMjZjNS41LDAsMTAtNC41LDEwLTEwbDMsNCIvPg0KPHBhdGggY2xhc3M9InN0MCIgZD0iTTE2LDZDMTAuNSw2LDYsMTAuNSw2LDE2bC0zLTQiLz4NCjwvc3ZnPg0K",
"name": "DynamicTiledSpriteChanger",
"previewIconUrl": "https://asset-resources.gdevelop.io/public-resources/Icons/Line Hero Pack/Master/SVG/Files and Folders/74b697fdb2d38d4341d1c9f2699d083c42f34ef4bdca8235f7d6d039c614fc22_Files and Folders_folder_exchange.svg",
"shortDescription": "Change the tiled sprite of your object to another dynamically.",
"version": "0.0.1",
"description": [
"# Dynamic tiled sprite change",
"",
"With this tool you will be able to change the sprites of your objects dynamically, which will allow for various business rules, such as a floor that changes theme automatically or skins for your character.",
"The possibilities are immense.",
"",
"This extension was made thinking about the template that I will soon sell for a complex character customization scene for RPG.",
"",
"The extension is for community and non-profit use, please use it giving due credit to me and @arthuro555 who made the extension I based it on \"Load images from a URL\". My thanks @arthuro555."
],
"tags": [
"tiledsprite",
"change sprite",
"sprite dynamic"
],
"authorIds": [
"K9dSRUFvF1gLdpt10P6itA2bi652",
"ZgrsWuRTAkXgeuPV9bo0zuEcA2w1"
],
"dependencies": [],
"eventsFunctions": [
{
"async": true,
"description": "Replaces the image contained by a sprite by a new one, from a URL. This will only affect the sprite in question and only until the image in it is changed through its animation or another action, unless you also modify the resource.",
"fullName": "Load Path/URL into a tiled sprite",
"functionType": "Action",
"name": "ChangeSpriteOfTiledSpriteFromPathOrURL",
"sentence": "Load PATH/URL String _PARAM1_ into sprite _PARAM2_ and change height _PARAM3_ and change width _PARAM4_ (and into the corresponding resource: _PARAM5_)",
"events": [
{
"type": "BuiltinCommonInstructions::JsCode",
"inlineCode": [
" ",
" const pathURL = eventsFunctionContext.getArgument(\"Path_URL\");",
" const customTexture = PIXI.BaseTexture.from(pathURL);",
" const changeResource = eventsFunctionContext.getArgument(\"ChangeResource\");",
"//Resolver o problema de ordem de renderização. Do jeito que esta apenas o primeiro item é modificado.",
" if (changeResource) {",
" customTexture.height = eventsFunctionContext.getArgument(\"SpriteSheetHeight\");",
" customTexture.width = eventsFunctionContext.getArgument(\"SpriteSheetWidth\");",
" for (const obj of objects) obj.getRendererObject().texture.baseTexture = customTexture; ",
" } ",
" "
],
"parameterObjects": "SpriteSheets",
"useStrict": true,
"eventsSheetExpanded": false
}
],
"parameters": [
{
"description": "The Path/URL to load the new image for the tiled sprite from",
"name": "Path_URL",
"type": "string"
},
{
"description": "The object to modify",
"name": "SpriteSheets",
"supplementaryInformation": "TiledSpriteObject::TiledSprite",
"type": "objectList"
},
{
"description": "Altura em pixels do seu spritesheet (altura total, não dos frames)",
"name": "SpriteSheetHeight",
"type": "expression"
},
{
"description": "Largura em pixels do seu spritesheet (altura total, não dos frames)",
"name": "SpriteSheetWidth",
"type": "expression"
},
{
"description": "Modify the resource?",
"longDescription": "If yes, modifies the image contained in the resource of the sprite's current frame instead of just the sprite's displayed image. This makes the changes affect all other sprites that also display this resource, and allows the change to persist after changing animations or the current frame.",
"name": "ChangeResource",
"type": "yesorno"
}
],
"objectGroups": []
}
],
"eventsBasedBehaviors": [],
"eventsBasedObjects": []
}