![]() |
TLN_SetSpriteBlendMode to highlight items - Printable Version +- Tilengine - The 2D retro graphics engine forum (http://tilengine.org/forum) +-- Forum: English forums (http://tilengine.org/forum/forumdisplay.php?fid=3) +--- Forum: Support (http://tilengine.org/forum/forumdisplay.php?fid=7) +--- Thread: TLN_SetSpriteBlendMode to highlight items (/showthread.php?tid=177) Pages:
1
2
|
TLN_SetSpriteBlendMode to highlight items - JaumeAlcazo - 09-03-2018 Hello everybody, I used TLN_SetSpriteBlendMode(id,BLEND_ADD,1); and TLN_SetSpriteBlendMode(id,BLEND_NONE,1); to highlight and de-highlight inventory items in my game when player hovers the mouse over them. BLEND_ADD looks good but the effect is too subtle, I would like to use a BLEND_ADD but with more strength. Any tips on this? Or maybe a parameter that lets you set the strength (but I think this is the third deprecated parameter). Best regards. RE: TLN_SetSpriteBlendMode to highlight items - RexyDallas - 09-03-2018 You can always use BLEND_CUSTOM to define your own blend function. The documentation on TLN_SetCustomBlendFunction() seems to have the information you'd need to do this. RE: TLN_SetSpriteBlendMode to highlight items - JaumeAlcazo - 09-03-2018 Thank you very much. There is any example of calling this function? The function-parameter and "components" intensity look strange, it would be useful to start from a given example. RE: TLN_SetSpriteBlendMode to highlight items - megamarc - 09-04-2018 Hi guys, I think about two ways to handle this -and probably a combination of both-: 1. Different palettes Clone the palette of the object to have a "highlighted" version, and lighten it with TLN_AddPaletteColor() . Alternatively you can craft a different palette in a graphic editor and load it with TLN_LoadPalette(). When you want to lighten the selected object, use TLN_SetSpritePalette() to pass the lighted palette, and call it again with the original palette when to restore it. Remeber to get a reference to the original palette with TLN_GetSpritePalette(). Assuming you are modifying sprite 0: Code: /* grab the original palette */ 2. Custom blending As pointed out by RexyDallas, you can create a custom blend function. Proper documentation is lacking. The idea is that you create a transfer function between the intensities of color components of the image you want to draw and the image below it, and return a new intensity. For example to multiply the intensity of the source image by 2 and then add to the destination, you would do something like this: Code: /* your blend function: source*2 + deination, clamped to 0-255 */ I haven't compiled this, there may be some typos but you get the idea RE: TLN_SetSpriteBlendMode to highlight items - JaumeAlcazo - 09-05-2018 Thank you very much for your answers, time and code. I will try that. RE: TLN_SetSpriteBlendMode to highlight items - Domarius - 09-06-2018 I'd say the palette swapping method was the traditional approach. In my game I just released, Jump-n-Bump, each menu option is a sprite with 2 frames of animation - very ham-fisted, but it was made in Godot and it doesn't have palette swapping. When I make my next game in Tilengine, I'll be using palette swapping for a lot of things! RE: TLN_SetSpriteBlendMode to highlight items - JaumeAlcazo - 09-10-2018 It worked like a charm. Congratulations for your game Domarius! RE: TLN_SetSpriteBlendMode to highlight items - megamarc - 09-11-2018 Haha what a cute guts-fest your jump-n-bump game Domarius ![]() ![]() RE: TLN_SetSpriteBlendMode to highlight items - Domarius - 09-12-2018 Thanks guys ![]() RE: TLN_SetSpriteBlendMode to highlight items - megamarc - 09-13-2018 Yeah Domarius throw away that Godot thing and "jump" to tilengine ![]() Talking about Mac, let me know when you attempt to build it. I don't have a Mac, I build for it with a modified version of VMWare and a pirated copy of OSX 10.11 "El Capitan". But it works. And Tilengine is also more downloaded in OSX than in linux (but the undisputed king is Windows 64-bit) |