Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Colour Cycling
#6
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

Code:
ok = _tln.TLN_SetSpriteBlendMode(self, mode)

to

Code:
ok = _tln.TLN_SetSpriteBlendMode(self, mode, 0)
(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:

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.
Reply


Messages In This Thread
Colour Cycling - by PerspexSphinx - 04-18-2018, 06:09 AM
RE: Colour Cycling - by megamarc - 04-19-2018, 03:51 AM
RE: Colour Cycling - by PerspexSphinx - 04-28-2018, 06:08 AM
RE: Colour Cycling - by megamarc - 04-28-2018, 11:37 PM
RE: Colour Cycling - by PerspexSphinx - 04-29-2018, 02:53 AM
RE: Colour Cycling - by megamarc - 04-30-2018, 04:06 PM
RE: Colour Cycling - by PerspexSphinx - 05-06-2018, 03:33 AM
RE: Colour Cycling - by megamarc - 05-07-2018, 10:50 PM
RE: Colour Cycling - by PerspexSphinx - 05-17-2018, 03:36 AM
RE: Colour Cycling - by megamarc - 05-21-2018, 07:18 AM
RE: Colour Cycling - by PerspexSphinx - 05-31-2018, 02:33 AM
RE: Colour Cycling - by megamarc - 06-02-2018, 01:19 AM
RE: Colour Cycling - by PerspexSphinx - 02-27-2019, 08:26 AM
RE: Colour Cycling - by megamarc - 02-28-2019, 07:43 AM
RE: Colour Cycling - by PerspexSphinx - 04-26-2019, 05:24 PM
RE: Colour Cycling - by megamarc - 05-01-2019, 09:31 PM

Forum Jump:


Users browsing this thread: 1 Guest(s)