Set Sprite color tone error

Hi,

 I was trying to change the color tone of a sprite by calling

spriteName.setColorTone([r, g, b, grey]);but if i put any values besides [0, 0, 0, 0]  like for example [1, 0, 0, 0] the sprites just disappears.

Any ideas? Thanks
any error on console?
no errors, if i change the value it disappears and if i set it back to [0,0,0,0] appears again.

I tried to see if i was passing the value in a wrong format so i used the command spriteName.getColorTone() before modifying it to see what was the default value and it returns [0,0,0,0]
I tried also to pass both values betreen 0 and 255, 0 and 1, and also negative ones but nothing worked.

At this point i'm starting to think maybe is a bug, documentation in reguarrds is pretty straight forward:

Immagine.png


Maybe is not specified and r,g,b,gray are not Number type but something else (in that case spriteName.getColorTone() shouldnt' return [0,0,0,0]) I'll check now 

EDIT: I just cheched,  typeof spriteName._colorTone[0] returns "Number", so it's not hte problem
actually, it works fine for me.

Spoiler
Y6G0Mj.png


using [255,0,0,0]
can you show the full script and what sprite?
The whole code is a bit long but this is basically what happens related to the topic:

var sprite = new Sprite();var spriteBitmap = ImageManager.loadPicture('image');sprite.bitmap = spriteBitmap;sprite.setColorTone([100,0,0,0]);SceneManager._scene.addChild(sprite);The only thing is that i tried this code alone by inputting it into the console and it worked, wonder what did i do wrong in the rest of the code, maybe is the fact that addChild() is calle every cicle now (which i know it shouldnt' be like that, but i left like that while  i was testing some things). I'll try to fix the code

EDIT: I solved the issue, addChild() and a line similar to this "sprite.bitmap = image" where called every cicle instead of just once at the start of the program, i fixed it and i works now, but i discovered that this effects sucks if the image has an alpha channel which has not  just 255 or 0 values 😛 .

Immagine.png


  Original     Modified

Anyway thank you 🙂 , I think i'll try to write a Sprite.prototype.setHue() at this point
Just a little question, if I would do a thing like this

FunctionX = function(hue) { var bitmap = ImageManager.loadPitcure('image', hue); sprite.bitmap = bitmap;};the memory allocated for bitmap will be cleared once the code gets out the scope of the function right?

Or every time is alle a new meory portion is assigned to bitmap and sprite.bitmap becomes just a pointer of it (while the previous bitmap memory gets garbage collected)?

The fact is that i would like to choose whenever i want the hue of the bitmap, but this things don't work:

Code:
// source image is loaded only oncevar sourceBitmap = new Bitmap(ImageManager.loadPitcure('image'));var sprite1 = new Sprite();var sprite2 = new Sprite();sprite1.bitmap = sourceBitmap;sprite2.bitmap = sourceBitmap;sprite1.bitmap.rotateHue(100); // Changes the hue also of sprite2, it modifies source bitmap which sprite1.bitmap referes to

Original thread: https://forums.rpgmakerweb.com/threads/set-sprite-color-tone-error.52890/