GMLscripts.com

Discuss and collaborate on GML scripts
Invert

You are not logged in.

#1 2013-11-12 15:28:38

NervaL928
Member
From: France
Registered: 2013-11-11
Posts: 10

sprite_replace_color() error... A bit annoying :)

Okay guys :), today I found a problem with a script that I needed, so here's this script :
http://www.gmlscripts.com/script/sprite_replace_color

I posted a comment showing that I had an error, so to recap I get this happening :
http://img5.imageshack.us/img5/3862/5lil.png

I get as an answer to check if the sprite was Fully Black, which I did before posting my first comment in fact ;)
But this was a good idea in fact, so I re-checked it, and RGB color for the sprite is #000000 for all the sprite.

I was told to add more info, but I don't know what I can tell you more, if it's not the code in the object (script is exactly the same) :

Spoiler

In step event for the player (object called objectCharacter) :
sprite_replace_color(spriteCharacter,c_black,c_aqua)


v4gh.png

Offline

#2 2013-11-12 16:56:40

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: sprite_replace_color() error... A bit annoying :)

I need to see a simple *.gmk project that demonstrates the problem. As I said in the comment, the black portions of the sprite that do not change are not #000000 in your image. I want to know what could be causing that. It's very strange.


Abusing forum power since 1986.

Offline

#3 2013-11-13 06:23:40

NervaL928
Member
From: France
Registered: 2013-11-11
Posts: 10

Re: sprite_replace_color() error... A bit annoying :)

Okay, I'm at school now, so Imma upload it for you this evening ;P


v4gh.png

Offline

#4 2013-11-13 14:39:31

NervaL928
Member
From: France
Registered: 2013-11-11
Posts: 10

Re: sprite_replace_color() error... A bit annoying :)

Okay, so now I have the file !
Get in from my DropBox now : https://www.dropbox.com/s/v1igub18ccem7 … _color.gmk

Edit : now it recolors the full sprite into transparent one tongue

Last edited by NervaL928 (2013-11-13 14:40:03)


v4gh.png

Offline

#5 2013-11-13 15:56:51

xot
Administrator
Registered: 2007-08-18
Posts: 1,201

Re: sprite_replace_color() error... A bit annoying :)

The main problem is the sprite is not entirely black.

hTIpmzY.png
The black areas are #000000, the blue areas are #010101, the red areas are #020202

GM8's sprite editor may have mislead you. I've noticed that the color tolerance controls don't work as expected and the magic wand and bucket fill tools don't reveal the problem. If you use the color picker tool on the marked areas, you can see their real color values in the color selection dialog.

There are a couple of usage problems as well, which should be better explained in the script.

First, this script should not be used in the draw event. This is because it has to draw to a surface to work.

GM8 Help File wrote:

You should never change the drawing target while you are actually drawing on the screen, that is, never use it in drawing events. This will cause serious problems with the projection and viewport.

Second, this script should only be run once per color replacement. Since it changes the sprite permanently, there is no reason to run it again. It's a relatively slow script and there may be a chance the sprite could degrade after many copies. I believe I've fixed the degradation problem but it was an issue in the past.


Abusing forum power since 1986.

Offline

Board footer

Powered by FluxBB