• Hello [name]! Thanks for joining the GMC. Before making any posts in the Tech Support forum, can we suggest you read the forum rules? These are simple guidelines that we ask you to follow so that you can get the best help possible for your issue.

Legacy GM Replacing a sprite from a external file directory Problems

F

Fibonacci

Guest
I am making a program to pose characters using a ragdoll setup and I have been trying to make it possible to replace a sprite for a body part from external image file directory.

.png 200x200

But when I replace say the left arm on one doll, all the left arms of all the other dolls change aswell!

I would like only the part I have selected to change, while keeping the other parts as the images I previously selected for them.

This is the basic code I am using
Code:
Create
Held=false;
me=sprite_index

Step

if id=global.selctall
{Held=true}
else
{Held=false;}

<Shift>
if Held=true
{
if sprite_exists(me)
   {
   var orspr = sprite_add(get_open_filename_ext("Image File|*.png;*","", working_directory, "Load A Part"),1,false,false,90,90);
   sprite_assign(me,orspr);
   sprite_delete(orspr);
}
}
I have also tried this.

Code:
<Shift>

if Held=true
{
{
var file;
file = get_open_filename_ext("Image File|*.png;*","", working_directory, "Load A Part");
if file != ""
   {
sprite_replace(me,file,1,false,false,90,90);
}
}
   global.selctall=noone
}
I know the code is a bit rough but any help would be appreciated.

Summary.
Replacing sprites to make multiple unique characters from externally drawn images
 

TsukaYuriko

☄️
Forum Staff
Moderator
To quote the manual:
https://docs.yoyogames.com/source/dadiospice/002_reference/game%20assets/sprites/sprite_assign.html said:
This function takes two previously created (or included) sprite indexes, and copies the image from one to the other. In this way you can copy (or "clone") one sprite into another index. Note that you cannot copy to a game resource. You have to have created the sprite to be copied to previously using the sprite_add or sprite_duplicate functions.
https://docs.yoyogames.com/source/dadiospice/002_reference/game%20assets/sprites/sprite_replace.html said:
This function works in almost the exact same manner as sprite_add, only instead of returning the index of the sprite you are importing, it overwrites a previously created sprite index. You must use a sprite index that has been created and stored in a variable using other functions like sprite_add or sprite_create_from_surface, and not one from the resource tree as you cannot replace built-in assets.
 
Top