Reputation: 491
I am absolutly beginner in JavaFX. I have JavaFX class Sprite :
public class Sprite extends CustomNode {
protected var xPos : Integer;
protected var yPos : Integer;
public function setxPos(){
this.xPos=50;
}
public function getxPos():Integer{
return this.xPos;
}
public function move() : Void{
xPos=xPos+2;
}
}
I use instance of this class in class Main. I set vaule of variable with function setxPos(). When I print value of variable, value is 0. This is code from class Main.
var sprite : Sprite;
sprite.setxPos(50);// use setter
println(sprite.getxPos());// value is 0
sprite.xPos=50;// without setter
println(sprite.getxPos());// value is 0 too
Where is problem ?? Thakns.
Upvotes: 0
Views: 298
Reputation: 159576
There is no such function setxPos(value: Integer)
defined for the setter - you only have a setxPos()
function without an argument and even then it hardcodes the value to 50 - it seems unlikely that your sample code would even compile.
I advise ditching JavaFX 1.x and the JavaFX Script language as they will be completely unsupported by Oracle by the end of the year and Oracle will switch off the runtime distribution server for these technologies.
Instead put your time into learning JavaFX 2, which is just written in the Java language for which there are many tutorials. To learn JavaFX 2, read and follow the examples in the JavaFX 2 documentation.
Here is a blog reference which contains an excellent example of JavaFX 2 sprite animation.
Upvotes: 1