How to make transparent part of a sprite in a Java 2D Game?
I'm making a 2D tile based game and I need to make part of a sprite transparent. I assume I should choose a determinate color and tell Java "Please Java, don't draw any pixel of this color.", but I don't know how t开发者_JAVA技巧o do it. I already googled it but I only get results about "alpha".
Also how can I "set priority" to my sprites so that the ones with high priority are always drawn in the front?
Thanks.
Use png files for the sprites. Java will draw transparent parts of png files transparently.
As for the sprite ordering, this is difficult to advise without any knowledge of your game's code structure. You could give each sprite a Z-index, sort and draw in order.
This KineticModel
creates multiple, translucent instances of GradientImage
as part of a simulation.
精彩评论