I have very little experience with coding and for my University Project Prototype, I need to code an image (a PImage in Processing) to move using my hands (Leap Motion Controller Input).
At the moment I am stuck on how to get my image to move using the position of my hand, but the error pops up saying that the image can only use floats as inputs since the position of the hand is calculated using the PVector class. I tried to use float[] (name) = handpos.array(); to make it a float value but then I can't get the x and y value from the position needed for the image.
Here is the code I have done so far, in the for loop, was where I was planning on adding the image to appear.
import de.voidplus.leapmotion.*;
LeapMotion leap;
//Assets
PImage hand;
//Colours
color ocean = color(50,113,250);
void setup(){
size(700, 700);
background(255);
leap = new LeapMotion(this);
hand = loadImage("images/hand.png");
imageMode(CENTER);
}
void draw() {
background (ocean);
int fps = leap.getFrameRate();
for (Hand hand : leap.getHands ()) {
Finger index = hand.getIndexFinger();
PVector hpos = hand.getPosition();
PVector ipos = index.getPosition();
}
}
If I understand your problem correctly, you can do it like this: