Set Sprite color tone error

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
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
 

izyees

My Secret Santa
Veteran
Joined
Oct 24, 2015
Messages
248
Reaction score
67
First Language
english
any error on console?
 

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
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:



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
 
Last edited by a moderator:

izyees

My Secret Santa
Veteran
Joined
Oct 24, 2015
Messages
248
Reaction score
67
First Language
english
actually, it works fine for me.



using [255,0,0,0]
can you show the full script and what sprite?
 

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
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 :p .



  Original     Modified

Anyway thank you :) , I think i'll try to write a Sprite.prototype.setHue() at this point
 
Last edited by a moderator:

orcomarcio

Veteran
Veteran
Joined
Nov 26, 2015
Messages
106
Reaction score
20
First Language
Italian
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
 
Last edited by a moderator:

Users Who Are Viewing This Thread (Users: 0, Guests: 1)

Latest Threads

Latest Profile Posts

Couple hours of work. Might use in my game as a secret find or something. Not sure. Fancy though no? :D
Holy stink, where have I been? Well, I started my temporary job this week. So less time to spend on game design... :(
Cartoonier cloud cover that better fits the art style, as well as (slightly) improved blending/fading... fading clouds when there are larger patterns is still somewhat abrupt for some reason.
Do you Find Tilesetting or Looking for Tilesets/Plugins more fun? Personally I like making my tileset for my Game (Cretaceous Park TM) xD
How many parameters is 'too many'??

Forum statistics

Threads
105,859
Messages
1,017,030
Members
137,566
Latest member
Fl0shVS
Top