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
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
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)
Follow same concept i provided it will work
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:
-
Make the borders with sprites. When the ball collides with the red one, you lose.
-
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.
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.