0
\$\begingroup\$

I want to draw a rect with a 50x50 size, however I want it to appear randomly on the x position. Where should i set the x position?

This is how i set my rectangle.

rectangle.set(50, 50, 100, 100);

I've done several changes on this setting the but I can't figure it out.

\$\endgroup\$
1
  • \$\begingroup\$ generate a random number, assign that number to x and pass x to rectange.set \$\endgroup\$
    – Lynob
    Feb 5 '17 at 15:44
0
\$\begingroup\$

You need to do the following:

rectangle.set(randomX, 50, randomX + 50, 100);

Where randomX is the random value.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .