Main Menu

Confusion Re: Map Level Transparency

Started by Jupei, June 26, 2008, 03:05:18 PM

Previous topic - Next topic

Jupei

I'm trying to learn how to work with maps and levels.
I can't seem to figure out how to render 2 layers of levels (foreground and background) with transparency, so that the transparent pixels in the foreground show through to the background. Its my understanding thats how "levels" are supposed to work so it should be possible right? Here the tiles I made:

As they should appear:


With 255 green as a mask:


As a transparent PNG:


Here is my code:
PlayBASIC Code: [Select]
Map1=NewMap(2)

;Load Map Tile Image
LoadImage "td_tiles_green.png",1
ImageMaskColour 1, RGB(0,255,0) ; Right/Wrong?

;Assign MapGFX attached to MyMap with 255G as "transparentColour"
MakeMapGFX Map1,1,32,32,32,RGB(0,0,0)

;Create 2 Levels, BG and FG
ForeGround=NewLevel(Map1,25,18)
BackGround=NewLevel(Map1,25,18)

;Fill ForeGround with highly transparent tiles from top row of tiles
For X = 0 To 25
For Y = 0 To 18
T = T + 1
PokeLevelTile Map1,ForeGround,X,Y,T
If T = 7 THEN T = 0
Next Y
Next X

;Fill BackGround with dark background tiles
T = 15
For X = 0 To 25
For Y = 0 To 18
T = T + 1
PokeLevelTile Map1,BackGround,X,Y,T
IF T = 17 THEN T = 15
Next Y
Next X

;draw BG Level at 0,0
DrawMap Map1,BackGround,0,0

;draw FG Level at offset to check for transparency
DrawMap Map1,ForeGround,16,16

sync
waitkey



Here is what I end up with:


All that green should be transparent... I have tried setting the ImageMaskColour of the tiles image to green. I have tried setting the "TransparentColour" flag in MakeMapGFX to green. I've tried doing them both together. If I just use a transparent PNG, the green just changes to blue... What am I missing?

Thanks in advance.

kevin


Jupei

Excellent. Thank you.

;Create 2 Levels, BG and FG, make FG transparent on 255G
ForeGround=NewLevel(Map1,25,18)
BackGround=NewLevel(Map1,25,18)
LevelTransparent Map1,ForeGround, 0



kevin

  Glad it works..  Any reason you're using a really old version of V1.63 ?

Jupei

Nope, just never upgraded after purchasing.

I will patch up to 1.63w if its going to keep you up at night. ;D

kevin


Ahh, just thought you might be running the old demo..