Color Switch on a Canvas

Hello, Please Is it possible to create a uniform color change on one edge of a canvas?
I am designing an app where I’ll be controlling a ball sprite to hit all but one edge of the canvas to score a point.
The four sides of the canvas should randomly turn a particular color one at a time

1 Like

you can do it logically…
suppose bottom position is 200 and right positon is 300

like as we know that position of
TopLeft - 0,0
TopRight - 300,0
BottomLeft - 0,200
BottomRight - 300,200

So on screen initialization you can draw a line of different colour from these coordinates

1 Like

Thanks, I forgot to give this illustration;


It should seem like the red line is moving randomly on the four sides (one side at a time)

1 Like

Follow same concept i provided it will work

2 Likes

Thanks but, the line does not stop the ball sprite’s movement and I plan that touching such line should take one chance away from the user

2 posible solutions, you decide which one is easier:

  1. Make the borders with sprites. When the ball collides with the red one, you lose.

  2. If you don’t want to use sprites, draw the lines randomly and when drawing the red line, save in a variable which border is the red line. When the ball reaches an edge, check if that edge is the same saved in the variable.

1 Like

I think the number depends on the length and width of the canvas. If the width is 100 pixels and the height is 156 px, then the

  • TopLeft is 0,0
  • TopRight is 100,0
  • BottomLeft, 0,156
  • BottomRight is 100,156

I think it’s like this, but if you are using Percent% or Fill parent, change the italics to Canvas:Width, then change the bold one to Canvas:Height. I usually do it this way. I hope this is correct.