# Moving to next trial when joystick hovers over image stimuli

**URL:** https://discourse.psychopy.org/t/moving-to-next-trial-when-joystick-hovers-over-image-stimuli/24545
**Category:** Builder
**Created:** [August 14, 2021, 10:43am UTC](https://discourse.psychopy.org/t/moving-to-next-trial-when-joystick-hovers-over-image-stimuli/24545 "2021-08-14T10:43:34Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![dxm986](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dxm986](https://discourse.psychopy.org/u/dxm986)
#### Post date: [August 14, 2021, 10:43am UTC](https://discourse.psychopy.org/t/moving-to-next-trial-when-joystick-hovers-over-image-stimuli/24545/1 "2021-08-14T10:43:34Z")

</div>

OS\*\* (e.g. Win10): win 10,  
PsychoPy version\*\* (e.g. 1.84.x): 3  
What are you trying to achieve?: Moving on to next trial when joystick hovers over an image without a button click.

My task involves moving a ‘cursor’ (.png) with a joystick to 5 different targets on the screen. Each trial requires movement to a different target. Once the ‘cursor’ reaches the target the task moves on to the next trial. I have created the 5 static images and a ‘cursor image’ which can be moved with the joystick. The target order the subject moves the cursor to is controlled by a 6th image that alternates between the position of the 5 static images but is a different colour. This makes it look like the static images a changing colour. See below.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/c/1/c1d9ae7f4ab0da08dfd2276da87ef6aa65e8cbaa.png)

What is not working:  
I have entered the code below to stop the routine and move to next trial when the static image1 contains the joystick but I get the error below.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/8/4/8455ecd9717bddf32c0b610a5e80987b3fe0619d.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/5/4/54fa209eb50c7978461d96d422d83e33d7bf735e.jpeg)

Thank you for your help in advanced.

Dave

---

<div class="post-metadata">

### Author: ![Luke](https://sea2.discourse-cdn.com/flex002/user_avatar/discourse.psychopy.org/luke/32/30321_2.png) [@Luke](https://discourse.psychopy.org/u/Luke)
#### Post date: [August 14, 2021, 5:31pm UTC](https://discourse.psychopy.org/t/moving-to-next-trial-when-joystick-hovers-over-image-stimuli/24545/2 "2021-08-14T17:31:45Z")

</div>

Probably an easy solution:

Joystick.getX()  
Joystick.getY()

Are missing the brackets in your code (resulting in the ‘int’ and ‘function’ error, because: .getX is returning the function not the value).

---

<div class="post-metadata">

### Author: ![dxm986](https://avatars.discourse-cdn.com/v4/letter/d/d9b06d/32.png) [@dxm986](https://discourse.psychopy.org/u/dxm986)
#### Post date: [August 15, 2021, 11:02pm UTC](https://discourse.psychopy.org/t/moving-to-next-trial-when-joystick-hovers-over-image-stimuli/24545/3 "2021-08-15T23:02:45Z")

</div>

Thank you Luke, that has worked perfectly. I am also hoping to collect continuous positional data for the joystick. When I select ‘end routine on press’ - never and ‘save joystick state’ - every frame. I get the following error.

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/a/6/a69a7675213fe4ab408165f9b155965a3282624b.png)

 ![image](https://us1.discourse-cdn.com/flex002/uploads/psychopy/original/3X/2/2/22a4b7de52269560ada1f34e899cb93373fc537a.jpeg)

As before any help is appreciated.

Dave
