On Thu, Aug 1, 2013 at 5:33 PM, Daniel Gillet <[email protected]>wrote:
> Hello,
>
> First post for me and I'm still learning Cocos2d. So bear with me.
>
Welcome,
>
> I played a bit with test_tmx.py. I added this code
>
> def on_key_press(key, modifier):
> if key == pyglet.window.key.Z:
> if scroller.scale == .75:
> scroller.do(actions.ScaleTo(1, 2))
> else:
> scroller.do(actions.ScaleTo(.75, 2))
> elif key == pyglet.window.key.D:
> test_layer.set_debug(True)
> elif key == pyglet.window.key.F:
> test_layer.set_cell_color(0, 0, (255, 0, 0) )
>
> I notice that this colorize indeed first cell (bottom left), but the black
> region is still black. This seems to make sense as the colors are
> multiplied, if I understood correctly. What should I change if I would like
> to have a reddish hue on this cell.
>
How vertex colors interacts with texture depends on the blend mode and
texture properties. The blend mode is global to the batch that draws the
tilemap, the texture properties is shared between the tiles with the same
image, so I think you can modify locally the multiplicative blend.
A naive way to do the effect can be: paint all the window to red before
painting the tilemap, the normal tiles draw with opacity 255 so no red for
them; to highlight the tile set opacity to 128.
That can be easily acomplished:
paint the full window with red: call glClearColor(255, 0, 0, 255) in
scene.on_enter
highlightr the tile with
test_layer.set_cell_opacity(0, 0, 128 )
un-highlight the tile with
test_layer.set_cell_opacity(0, 0, 255 )
> Also in this demo, when I use the scaling to 0.75, we see black lines
from the grid while the car is moving. Is there something I could do to
minimize this problem?
With the current pyglet + cocos the only safe zoom values are fractions
with a denominator that divides exactly the texture lenght.
By example, with 32 x 32 textures a scale of 1/2 is safe.
> And last question, if my intention was to draw a grid, how should I
proceed? Of course I could add another layer with its own grid, but I feel
like it's unnecessary duplication. The vertex are already there. Can we
still show the quads border while using textures?
A separate grid is probably the clean and easier.
Without that you need to redraw the tilemap in a mode that only draw
borders.
> Thanks for your help,
Dan.
--
You received this message because you are subscribed to the Google Groups
"cocos2d discuss" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/cocos-discuss.
For more options, visit https://groups.google.com/groups/opt_out.