Java-Gaming.org Hi !
Featured games (90)
games approved by the League of Dukes
Games in Showcase (798)
Games in Android Showcase (234)
games submitted by our members
Games in WIP (865)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  JavaFX blend effect using only one node (canvas)  (Read 1715 times)
0 Members and 1 Guest are viewing this topic.
Offline pavul

Senior Devvie


Medals: 4
Exp: 4 years



« Posted 2019-07-18 05:12:36 »

Hello everyone, its me again after a year, so i made progress using JavaFX for game Development as hobby, and basically what i am doing is putting a canvas in a node and that node in the stage, all the game is processed on that canvas, however, i would like to implement some blend effects, but so far all examples that exist online are using different nodes, does anyone knows if its possible to use blend using a sole canvas ( node ) instance?, i tried to make this with no result until now, thanks in advance.

its better not know why it works, that know why is not working
Offline philfrei
« Reply #1 - Posted 2019-07-19 02:29:52 »

I've only done a little bit with blending. I did this by changing the opacity property of various graphics being shown as ImageViews. Opacity is a property of Node, though, so it should be possible to make any Node opaque/transparent.

Can you show some code for what you tried?

music and music apps: http://adonax.com
Offline Shatterhand
« Reply #2 - Posted 2019-07-19 16:05:03 »

@philfrei That does work for normal Nodes, but things are a bit different for the Canvas.

@pavul Any reason why you use a Canvas? That's slower and not really better to handle IMO.
Anyway, you can set BlendModes: https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/effect/BlendMode.html in your GraphicsContext: https://openjfx.io/javadoc/11/javafx.graphics/javafx/scene/canvas/GraphicsContext.html

Perhaps that would help you? E.g. drawing a mask image with a certain blend mode to create a fade effect, or light effect, or whatever.

Cheers

Micro$oft broke Volkswagen's world record: Volkswagen only made 22 million bugs!
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline pavul

Senior Devvie


Medals: 4
Exp: 4 years



« Reply #3 - Posted 2019-07-19 16:14:22 »

I remember someone says that canvas or graphics context was powerful enough, however did not wanted to make another library like Almas is currently doing, I handle the opacity with alpha property pretty well, however when I want to change the color sprite for something red or yellow ( when I hit the sprite ) I think it can be done with blend, I was setting the blend effect to canvas but everything is a single node or a sole canvas in this case, so the blend effects don't overlap 2 nodes like the other examples have.

what I what to achieve for now is blend the sprite with some specific color and put a black surface on top and then make the effect of a flashlight just to make transparent the part where the flashlight is, I was thinking to create a black rectangle, put the flashlight on top, and with the pixel writer of the canvas make all flashlight pixels transparent, but I think that can be overwhelming.

its better not know why it works, that know why is not working
Pages: [1]
  ignore  |  Print  
 
 

 
Riven (31 views)
2019-09-04 15:33:17

hadezbladez (3964 views)
2018-11-16 13:46:03

hadezbladez (1440 views)
2018-11-16 13:41:33

hadezbladez (3961 views)
2018-11-16 13:35:35

hadezbladez (768 views)
2018-11-16 13:32:03

EgonOlsen (4083 views)
2018-06-10 19:43:48

EgonOlsen (4655 views)
2018-06-10 19:43:44

EgonOlsen (2752 views)
2018-06-10 19:43:20

DesertCoockie (3646 views)
2018-05-13 18:23:11

nelsongames (3839 views)
2018-04-24 18:15:36
Java Gaming Resources
by philfrei
2019-05-14 16:15:13

Deployment and Packaging
by philfrei
2019-05-08 15:15:36

Deployment and Packaging
by philfrei
2019-05-08 15:13:34

Deployment and Packaging
by philfrei
2019-02-17 20:25:53

Deployment and Packaging
by mudlee
2018-08-22 18:09:50

Java Gaming Resources
by gouessej
2018-08-22 08:19:41

Deployment and Packaging
by gouessej
2018-08-22 08:04:08

Deployment and Packaging
by gouessej
2018-08-22 08:03:45
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!