• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Devaka Cooray
  • Knute Snortum
  • Paul Clapham
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • Jeanne Boyarsky
  • Bear Bibeault
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Ron McLeod
  • Piet Souris
  • Frits Walraven
Bartenders:
  • Ganesh Patekar
  • Tim Holloway
  • salvin francis

Using 'if' with .setTranslateY  RSS feed

 
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have loaded image.
I have set its coordinates:


During program run, its coordinates can change.

I want to write 'if' condition.



This code above dont works. What I want to do? I want to write a code:

if character coordinates is Y=50 and X=0, then button A becomes invisible.


Heres a quick video, if I have not explained clear.
 
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I don't know JavaFX  but I guess you want to write something like:
 
bob john
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Correct, thanks.
 
Ranch Hand
Posts: 146
4
 
Tony Docherty
Bartender
Posts: 3323
86
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please BeForthrightWhenCrossPostingToOtherSites (← click).

We don't mind if you cross post but do tell us as we all give up our time here for free and would rather not waste it answering a question that has already been answered elsewhere.
 
Norman Radder
Ranch Hand
Posts: 146
4
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Learning how to read the API doc will be useful when writing java code.  For this problem, a scan of the API doc would have shown that the set method was defined as returning void and the associated get method would return a value that could be compared in an if statement.
 
Marshal
Posts: 64483
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You did say on the other forum that you read the documentation. They said there that

I do think that the proposed solution at coderanch is incorrect in the sense of the game though.

The answer given here did address the question you asked here; if you ask the wrong question however....
I would suggest you don't want to make buttons appear and disappear. That will make your GUI difficult to watch. Try something like this instead.
Also what is going to happen if you have multiple transforms applied to your sprite? Will you get exactly 50? Look at the Node documentation and scroll down to the first diagram with the sine wave on and read the Bounding Rectangles section.
 
Campbell Ritchie
Marshal
Posts: 64483
225
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Having read the documentation, I think maybe I have given you the wrong method. Maybe thisis better.
 
bob john
Ranch Hand
Posts: 117
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Everything fine for me.
I asked a question, who was portion of my algorithm.


 
Yes, my master! Here is the tiny ad you asked for:
ScroogeXHTML - small and flexible RTF to HTML converter library
https://coderanch.com/t/710903/ScroogeXHTML-RTF-HTML-XHTML-converter
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!