views:

162

answers:

1

I am using cocos2d on the iPhone and am wondering if it is possible to use a texture mask in order to create tile transitions / fringe layer. For example, a grass tile and a dirt tile, I would want a tile that had both grass and dirt in it... Has anyone done this, or is the only way to create one tile for every possible transition?

A: 

For those who are curious, you can use masks with the following setup:

First draw the mask which should use a black brush on a transparent background. Draw this with src alpha and one-minus src alpha.

Second, draw on top of the mask the texture that you only want to appear over the mask part (the black brush). Draw this texture with dst alpha and gl_zero.

Third, draw the texture that you want to appear over the transparent part of the mask. Draw this texture with one-minus dst alpha and gl_one.

Using this technique, you don't have to make transition / fringe tiles for all of the possible terrains.

John JJ Curtis