04-30-2018, 04:06 PM
Don't worry about posting questions, I appreciate your interest!
Short cause:
you found a bug in the python binding. I'll fix it on GitHub, meanwhile you can fix it yourself to proceed with your tests: Open tilengine.py file, and change line 1858 from
to
(add the last , 0 parameter to the end of the call)
Long cause:
I know the documentation may be incomplete and confusing sometimes. You told that you're using Python binding, but the documentation chapters (incomplete) are for the C API, and the syntax you're using in set_blend_mode() is an invalid mix of C and Python.
Please note that the C# and Python bindings are NOT a direct 1:1 translation from the original C API. The functionality is the same, but they use features of the target languages (classes instead of plain functions, properties, etc) that are expected by C# and Python programmers. It makes difficult to maintain a consistent documentation.
The Python binding has full docstrings, and you can find online reference here:
http://www.tilengine.org/doc_python/index.html
In regard to blending modes, in Python you must call set_blend_mode() method on a Sprite or Layer instance, you access them in the sprites[] and layers[] lists inside the Engine instance. This method accepts a single parameter, the blending mode:
http://www.tilengine.org/doc_python/tile...blend_mode
It would be something like this, the blending itself is on 6th line:
I hope it helps!
Short cause:
you found a bug in the python binding. I'll fix it on GitHub, meanwhile you can fix it yourself to proceed with your tests: Open tilengine.py file, and change line 1858 from
Code:
ok = _tln.TLN_SetSpriteBlendMode(self, mode)
to
Code:
ok = _tln.TLN_SetSpriteBlendMode(self, mode, 0)
Long cause:
I know the documentation may be incomplete and confusing sometimes. You told that you're using Python binding, but the documentation chapters (incomplete) are for the C API, and the syntax you're using in set_blend_mode() is an invalid mix of C and Python.
Please note that the C# and Python bindings are NOT a direct 1:1 translation from the original C API. The functionality is the same, but they use features of the target languages (classes instead of plain functions, properties, etc) that are expected by C# and Python programmers. It makes difficult to maintain a consistent documentation.
The Python binding has full docstrings, and you can find online reference here:
http://www.tilengine.org/doc_python/index.html
In regard to blending modes, in Python you must call set_blend_mode() method on a Sprite or Layer instance, you access them in the sprites[] and layers[] lists inside the Engine instance. This method accepts a single parameter, the blending mode:
http://www.tilengine.org/doc_python/tile...blend_mode
It would be something like this, the blending itself is on 6th line:
Code:
import tilengine as tln
engine = tln.Engine.create(400, 240, 0, 1, 0)
engine.set_load_path("../assets/smw")
spriteset = tln.Spriteset.fromfile("smw_sprite")
engine.sprites[0].setup(spriteset)
engine.sprites[0].set_blend_mode(tln.Blend.MIX)
window = tln.Window.create()
while window.process():
window.draw_frame()
I hope it helps!
(04-29-2018, 02:53 AM)PerspexSphinx Wrote: Hi again, sorry, I see that this is mentioned in chapter 07 of the docs, but then it says please refer to Chapter 09 - Blending, which doesn’t seem to have be written yet. But I am having trouble getting it to work, I’m afraid...
dragonSprite.set_blend_mode(0, BLEND_MIX, 0)
...I guess is not correct.
Could you just give an example of it using within the Python binding, and with different blend modes.