Jump to content

spriteTinter


LinkTree
 Share

Recommended Posts

Hi @LinkTree

 

I've been playing with the sprite tinter and for some reason, when I try to follow the instructions to set the 'tint' of my sprite, it just becomes invisible.

 

Not sure if I'm doing something wrong, but I can't seem to get it working :(

 

Thanks in advance!

 

Ok I think I found the reason your textures were not showing. you are working with a tablet or a smartphone with high resolution I fixed this issue in the latest update. you can try it now.

Link to comment
Share on other sites

Hi @LinkTree

 

Thanks for the quick reply, but I still can't get it to work.

 

The only code I have is this ...

 

to require ...

 

.require(

    'plugins.spriteTinter',
 
and when creating the sprite ...
 
var lightSwitch = new game.LightSwitch(240, 212, this.bg);
lightSwitch.tint = "#FF0000";
 
The lightswitch works fine without the tint, but when when the tint is added, it becomes invisible.
 
Hope this helps :)
Link to comment
Share on other sites

 

Hi @LinkTree

 

Thanks for the quick reply, but I still can't get it to work.

 

The only code I have is this ...

 

to require ...

 

.require(

    'plugins.spriteTinter',
 
and when creating the sprite ...
 
var lightSwitch = new game.LightSwitch(240, 212, this.bg);
lightSwitch.tint = "#FF0000";
 
The lightswitch works fine without the tint, but when when the tint is added, it becomes invisible.
 
Hope this helps :)

 

 

is game.LightSwitch a class extended from game.Sprite?

Link to comment
Share on other sites

Hmmmm ... that could be it! It's extended from game.Animation

 

Any way to get it going with anims?

 

Thanks for spotting that!

 

Hmmm... I just tried it with a game.Animation and it worked fine. did you override the default rendering of game.Animation with game.LightSwitch?

 

this worked for me:

var anim = new game.Animation(['eye.png','eye2.png']);anim.play();anim.tint = "#ff0000";anim.addTo(game.scene.stage);

Edit:

I haven't seen your game.LightSwitch code but my assumption is that the problem might be in it's init function.

Link to comment
Share on other sites

This is all I have in my LightSwitch class ...

game.createClass('LightSwitch', 'Animation', {    textures: ['lightSwitch0001.png', 'lightSwitch0002.png', 'lightSwitchInvisible.png'],    interactive: true,    buttonMode: true,    init: function(x, y, container) {        this.anchor.set(this.width/2, 0);        this.position.set(x, y);        this.addTo(container);        this.off = true;    },});

and then to put in on screen ...

var lightSwitch = new game.LightSwitch(240, 212, this.bg);lightSwitch.tint = "#FF0000";

Hmmm ... I might very well be doing something wrong. I'll see if I can get it going haha.

 

Thank for your help :)

Link to comment
Share on other sites

This is all I have in my LightSwitch class ...

game.createClass('LightSwitch', 'Animation', {    textures: ['lightSwitch0001.png', 'lightSwitch0002.png', 'lightSwitchInvisible.png'],    interactive: true,    buttonMode: true,    init: function(x, y, container) {        this.anchor.set(this.width/2, 0);        this.position.set(x, y);        this.addTo(container);        this.off = true;    },});

and then to put in on screen ...

var lightSwitch = new game.LightSwitch(240, 212, this.bg);lightSwitch.tint = "#FF0000";

Hmmm ... I might very well be doing something wrong. I'll see if I can get it going haha.

 

Thank for your help :)

 

 

this worked for me:

game.createClass('Anim','Animation',{    textures: ['eye.png', 'eye2.png'],    interactive: true,    buttonMode: true,    init: function(x, y, container){        this.anchor.set(this.width/2, 0);        this.position.set(x, y);        this.addTo(container);        this.off = true;    }});var anim = new game.Anim(100,100,game.scene.stage);anim.tint = "#ff0000";anim.play();

Maybe it is something else that causes it. are you getting any errors in your console?

Link to comment
Share on other sites

Now that you say so ... I am. I completely forgot to check (as everything else was working).

 

[Error] TypeError: undefined is not an object (evaluating 'game.FastContainer.inject')

(anonymous function) (spriteTinter.js, line 334)
_loadModules (core.js, line 712)
_loadModules (core.js, line 720)
body (core.js, line 260)
global code (sprite.js, line 10)
Link to comment
Share on other sites

 

Now that you say so ... I am. I completely forgot to check (as everything else was working).

 

[Error] TypeError: undefined is not an object (evaluating 'game.FastContainer.inject')

(anonymous function) (spriteTinter.js, line 334)
_loadModules (core.js, line 712)
_loadModules (core.js, line 720)
body (core.js, line 260)
global code (sprite.js, line 10)

 

Are you using the 2.0 version? I am not sure but I think the first error is due to game.FastContainer not existing and it indeed doesn't exist in the 1.3 version.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...