Hi Im writing a project based on your structure of Tiles (coding a 2048 game) I'd like to compare the content of a Tile to the empty string, to prevent the game from adding a new string on an allready filled tile with something like this : if(tiles.get(pos1) != ""), where pos1 is a randomly generated position for my number to be inserted in, and tiles is my ArrayList containing the tiles... As you may have guessed, this statement gives me an error, as it compares a Tile to a string... What should I do to correct it ?
If I use a for loop goes row by column to display the tiles and add each image to each tile by using stackpane, and then add the stackpane to gridpane to display game board. How do I compare the images??
I would use setUserData(imageName), where imageName is a String that identifies the image. Then comparison becomes trivial - you just compare the imageName.
It seems you can can prevent fast clicking by just using the event.getClickCount() as well. Just change if (isOpen() || event.getClickCount() > 1) return; } - there are a couple of extra null checks I added as well.
***** It seems to be a more elegant solution too since there is no need to introduce new variables. However, do be careful because click count is based on the delivery of native OS events and therefore is likely to demonstrate inconsistent results on different platforms. Here's more info if you are interested - docs.oracle.com/javase/8/javafx/get-started-tutorial/jfx-architecture.htm and docs.oracle.com/javase/8/javafx/api/javafx/scene/input/MouseEvent.html#getClickCount-- Nevertheless, as far as the tutorial is concerned sounds like a nice solution. Kind regards
Always get an error "Thread.java:745" and others associated with the flow. At the same time on the field remain open letters, even though they do not have a pair. What could be the reason and how can I fix it?
+Юля Короткина Hi, there must be something you've missed. You can check your code against the original here - github.com/AlmasB/FXTutorials/blob/master/src/com/almasb/mp/MemoryPuzzleApp.java
You could assign each image a unique id, such as file name. The next step would be, when creating an ImageView, to set a property, say "String imageID". Then comparing two ImageViews is trivial -- just compare their imageID.
Thank you for this tutorial! I tried to make this using images and a gridpane but for some reason the images don't vanish when they are different and I don't know why. Oo
Hi, I don't quite understand what you mean. Are you using an ImageView and want to make it transparent while keeping the stroke? Use StackPane with the rectangle being the first node and set its fill to null. That way you get the stroke around the rectangle but not the fill. Then, add an ImageView as the second node to StackPane and make it invisible or set opacity to 0. Reveal the image when needed. See if it helps.
hi after that how do we reveal the image?? I was planning to use a setonmouseclicked event and inside that event set the opacity to 1 but It does not show up
Hi, it allows us to obtain the remainder of the division. In practice, i % NUM_PER_ROW is less than NUM_PER_ROW. So, when setting the X position we will never go out of "bounds". Search for modulus division for more information.
Almas, I am totally grateful for his teachings, I have learned and had a lot of fun, my thanks for your channel
You sir are a life saver. I know have a complete working blue print for this assignment.
Hello! Could you make a tutorial like this using Scene Builder for the Memory Puzzle?
Hi
Im writing a project based on your structure of Tiles (coding a 2048 game)
I'd like to compare the content of a Tile to the empty string, to prevent the game from adding a new string on an allready filled tile with something like this : if(tiles.get(pos1) != ""), where pos1 is a randomly generated position for my number to be inserted in, and tiles is my ArrayList containing the tiles...
As you may have guessed, this statement gives me an error, as it compares a Tile to a string... What should I do to correct it ?
We want an example MVP with images can you help us
Has someone managed to fix the bug of the open tile?? I can't figure a way so I can determine if the animation has ended.
If I use a for loop goes row by column to display the tiles and add each image to each tile by using stackpane, and then add the stackpane to gridpane to display game board. How do I compare the images??
I would use setUserData(imageName), where imageName is a String that identifies the image. Then comparison becomes trivial - you just compare the imageName.
It seems you can can prevent fast clicking by just using the event.getClickCount() as well. Just change if (isOpen() || event.getClickCount() > 1) return; } - there are a couple of extra null checks I added as well.
***** It seems to be a more elegant solution too since there is no need to introduce new variables. However, do be careful because click count is based on the delivery of native OS events and therefore is likely to demonstrate inconsistent results on different platforms. Here's more info if you are interested - docs.oracle.com/javase/8/javafx/get-started-tutorial/jfx-architecture.htm and docs.oracle.com/javase/8/javafx/api/javafx/scene/input/MouseEvent.html#getClickCount-- Nevertheless, as far as the tutorial is concerned sounds like a nice solution. Kind regards
Almas Baimagambetov Good point. Thanks.
How do we check if all the tiles are opened,(the game is over)
Always get an error "Thread.java:745" and others associated with the flow. At the same time on the field remain open letters, even though they do not have a pair. What could be the reason and how can I fix it?
+Юля Короткина Hi, there must be something you've missed. You can check your code against the original here - github.com/AlmasB/FXTutorials/blob/master/src/com/almasb/mp/MemoryPuzzleApp.java
Hi can help me create a game using javafx?
If I was to make this game with images how do I compare their values?
You could assign each image a unique id, such as file name. The next step would be, when creating an ImageView, to set a property, say "String imageID". Then comparing two ImageViews is trivial -- just compare their imageID.
Hey !! can you tell me how can i put random imageview in array list ..?
+gurpreet singh try Collections.shuffle()
Thank you for this tutorial! I tried to make this using images and a gridpane but for some reason the images don't vanish when they are different and I don't know why. Oo
+YouKnowWho685 never mind i fixed it. ^^
I'm stuck there right now. How did you get it to fade out?
how did you do it ??
could you please share the code ?
How can I set image(rectangle Fill) opacity to 0, but keep the rectangle stroke?
Hi, I don't quite understand what you mean. Are you using an ImageView and want to make it transparent while keeping the stroke? Use StackPane with the rectangle being the first node and set its fill to null. That way you get the stroke around the rectangle but not the fill. Then, add an ImageView as the second node to StackPane and make it invisible or set opacity to 0. Reveal the image when needed. See if it helps.
Almas Baimagambetov Thanks, helped!
hi after that how do we reveal the image?? I was planning to use a setonmouseclicked event and inside that event set the opacity to 1 but It does not show up
Can you explain why is it (50 * (i % NUM_PER_ROW)); please?
Hi, it allows us to obtain the remainder of the division. In practice, i % NUM_PER_ROW is less than NUM_PER_ROW. So, when setting the X position we will never go out of "bounds". Search for modulus division for more information.
Thank you!
Could you do this game using FXML please? I would really appreciate that. Thank you in advance.
Please make Ludo King game in JavaFX.
Am not too understand about this vidio ,