get the x,y position of an image and convert it into a floating point?
in
Contributed Library Questions
•
2 years ago
Hi, Im really new to processing, as ive just started using it to develop a game for a Uni project where i have to make a game for kids.
I'm making a spelling game using TUIO's. so what i would like to do is assign a letter to every fiducial (ID's 1- 35).
Ive created a Hashmap for that and its working fine.
But in order to spell the words correctly the fiducials (letters) have to be placed in the correct order.
at the moment Ive written an IF statement that checks whether the correct symbols/fiducials are on the table and then give feedback whether Right or Wrong. But the problem is they can be placed in any order and still get it right.
so I made a .jpg of a small square (in photoshop), and if the word the kid has to spell is dog, I will display 3 squares in the window in linear fashion and the TUIO objects would have to fit into those squares in the correct order. e.g.
//this example is pseado code so its not fully correct
int letterCount=0;
hashmap = new hashmap
void setup(){
}
void draw(){
PImage square1 = loadImage("square.jpg";);
PImage square2 = loadImage("square.jpg";);
PImage square3 = loadImage("square.jpg";);
image (square1, 10,50);
image (square2, 30, 50);
image (square3,50, 50);
}
void addTuioObject(){
int fiducial = tobj.getSymbolID;
float xLocation = tobj.getX();
float yLocation = tobj.getY();
}
WHAT I WANT TO DO is check the x,y position of the TUIO and if its the same the x,y as square1/square2/square3 then increment letterCount++ and once letterCount==3 then check whether the letter the symbols from the hashmap are in the correct squares 1-3. (i know how to write the IF statement for that I just dont know how to get the x,y position)
two problems that arise is that:
1) the X, Y position of the TUIO object are always 0. decimal numbers (they go no higher than 0, no lower than 0 so theres no point converting them integers as it would just be 0) so they can't be compared the x,y position of the image.
2)when i I try and get the x, y position of the image 'square' using x+y*square1.width; I get the error message Component.x is not visible (don't know what that means??)
Can Any One Help Me??
1