Reset Tint Tile?

Very quick question… is it possible to reset a tile back to its original colour after using tintTile()?

I noticed that setting the fill colour back to “white” should restore the image: http://forums.coronalabs.com/topic/44314-how-to-remove-a-tint-on-an-image-after-applying-it/

???

Yes, the tint functions all work the same way, pass in white to change a tile, layer, or the map back its original color.

local locX = 1 local locY = 1 local layer = 1 local color = {1, 1, 1} --white local time = 1 mte.tintTile(locX, locY, layer, color, time)

That’s what I thought - however the following code is just making every tile black:

[lua]

for x = 1, mte.map.width do
        for y = 1, mte.map.height do
            print("x: "…x)
            print("y: "…y)
            mte.tintTile(x,y,6,{1,1,1},0)
        end
    end

[/lua]

I guess this is because 1 in the old Corona colour scheme is black? I changed the colour table to {255,255,255} and that changes all tiles to white - but no way of resetting back to original colour?!?

Instead of working through the tiles in a nested loop, I’ve tried changing my tint layer via:

[lua]

if not mte.tintLayer(6) then
        mte.tintLayer(6, {1, 1, 1}, 1, easing.inOutExpo)
end

[/lua]

But this again is just tinting everything black…

The {1, 1, 1} range is working on my end. Please double check that you’re using 0v984-7. Previous version still use the old 0-255 range.

I changed the colour table to {255,255,255} and that changes all tiles to white - but no way of resetting back to original colour?!?

Now, what exactly do you mean by white? Are the tiles actually turning flat, featurelessly white? I’m not sure what you mean by their original color. Is it that you’ve set the layer lighting and you want them to return to the layer lighting values? In the absence of layer lighting and all that jazz, setting them to white should return them to their original color, whether the range is 0-1 or 0-255.

Hey Dyson - thanks for following this up.

Firstly I’m still on 0v984-1 so I’ll upgrade this.

In regards to everything else - ignore me, think I’m being stupid :slight_smile:

There is no such thing as a stupid question!.. Well… I mean, there is, but I haven’t seen any from you or other customers yet!

Well thanks for the kind words…

Slightly related to this - I’m trying to tint a tile to highlight where the player’s chosen item will seed/water/etc… Would you have any advice on best practise for this?

Essentially I just what to highlight the tile that the accompanying object’s action will be associated with in its touch handler.

Currently I have a layer assigned specifically to this comprised of white tiles in Tiled. I fade this layer on loading the map and then wihtin the touch listener of said object I make a call to a method that calls fadeTile() on the highlighted tile from the touch listener and tries to raise its individual opacity.

Unfortunately it doesn’t appear to be working… If a layer is faded to 0 will I be able to increase the opacity of an individual tile?

In the touch handler I have this:

[lua]

local loc = self.m_pMap:convert( “screenPosToLoc”, event.x, event.y)
            self.m_pMap:tintTile(loc.x, loc.y)

[/lua]

Which makes  call to this method:

[lua]

function Game_Map:tintTile(x,y)
    print("TINT TILE: “…x…” / "…y)
    mte.fadeTile(x,y,6,0.5,10,easing.inOutQuad)
–    mte.tintTile(x,y,3,{255,0,0},0,easing.inOutQuad)
    
end

[/lua]

However I had previously faded this layer???

Yes, the tint functions all work the same way, pass in white to change a tile, layer, or the map back its original color.

local locX = 1 local locY = 1 local layer = 1 local color = {1, 1, 1} --white local time = 1 mte.tintTile(locX, locY, layer, color, time)

That’s what I thought - however the following code is just making every tile black:

[lua]

for x = 1, mte.map.width do
        for y = 1, mte.map.height do
            print("x: "…x)
            print("y: "…y)
            mte.tintTile(x,y,6,{1,1,1},0)
        end
    end

[/lua]

I guess this is because 1 in the old Corona colour scheme is black? I changed the colour table to {255,255,255} and that changes all tiles to white - but no way of resetting back to original colour?!?

Instead of working through the tiles in a nested loop, I’ve tried changing my tint layer via:

[lua]

if not mte.tintLayer(6) then
        mte.tintLayer(6, {1, 1, 1}, 1, easing.inOutExpo)
end

[/lua]

But this again is just tinting everything black…

The {1, 1, 1} range is working on my end. Please double check that you’re using 0v984-7. Previous version still use the old 0-255 range.

I changed the colour table to {255,255,255} and that changes all tiles to white - but no way of resetting back to original colour?!?

Now, what exactly do you mean by white? Are the tiles actually turning flat, featurelessly white? I’m not sure what you mean by their original color. Is it that you’ve set the layer lighting and you want them to return to the layer lighting values? In the absence of layer lighting and all that jazz, setting them to white should return them to their original color, whether the range is 0-1 or 0-255.

Hey Dyson - thanks for following this up.

Firstly I’m still on 0v984-1 so I’ll upgrade this.

In regards to everything else - ignore me, think I’m being stupid :slight_smile:

There is no such thing as a stupid question!.. Well… I mean, there is, but I haven’t seen any from you or other customers yet!

Well thanks for the kind words…

Slightly related to this - I’m trying to tint a tile to highlight where the player’s chosen item will seed/water/etc… Would you have any advice on best practise for this?

Essentially I just what to highlight the tile that the accompanying object’s action will be associated with in its touch handler.

Currently I have a layer assigned specifically to this comprised of white tiles in Tiled. I fade this layer on loading the map and then wihtin the touch listener of said object I make a call to a method that calls fadeTile() on the highlighted tile from the touch listener and tries to raise its individual opacity.

Unfortunately it doesn’t appear to be working… If a layer is faded to 0 will I be able to increase the opacity of an individual tile?

In the touch handler I have this:

[lua]

local loc = self.m_pMap:convert( “screenPosToLoc”, event.x, event.y)
            self.m_pMap:tintTile(loc.x, loc.y)

[/lua]

Which makes  call to this method:

[lua]

function Game_Map:tintTile(x,y)
    print("TINT TILE: “…x…” / "…y)
    mte.fadeTile(x,y,6,0.5,10,easing.inOutQuad)
–    mte.tintTile(x,y,3,{255,0,0},0,easing.inOutQuad)
    
end

[/lua]

However I had previously faded this layer???