Undefined (setting 'pos')

I am making a CYOA Game. Here on the first screen, there is an enter button and after clicking it you will be transferred to the next screen where you will have another screen with two buttons but the buttons on the second screen are not visible.

CYOA Game Starter Code - Replit

You have created two instances of the a1Button but didn’t create an instance for the a2Button.

1 Like

Still not working I am still not able to see buttons on second screen

You didn’t change. You are overwriting your a1Button instance. In the setup function, you’re creating a1Button twice and not creating a2Button at all.

This is in your script.js

Here:

a1Button = new Sprite(-200, -200);
a1Button = new Sprite(-50, -50);  // <-- The problem
b1Button = new Sprite(-100,-100);
b2Button = new Sprite(-150,-150);

You have to assign a second sprite to a2

a1Button = new Sprite(-200, -200);
a2Button = new Sprite(-50, -50);  // <-- Correct here
b1Button = new Sprite(-100,-100);
b2Button = new Sprite(-150,-150);

okay I got it now thank you

1 Like

If that solved your issue please mark the answer as the solution.

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.