Last active
August 19, 2021 21:20
-
-
Save juskek/5de5b9bbd7d5fb1d283472cb878f16ce to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
void render(Canvas canvas) { | |
/// BACKGROUND (BOTTOMMOST LAYER) | |
Rect bgRect = Rect.fromLTWH(0, 0, screenSize!.width,screenSize!.height); | |
Paint bgPaint = Paint(); | |
bgPaint.color = Color(0xffbbcc00); | |
canvas.drawRect(bgRect, bgPaint); | |
/// TARGET BOX (TOPMOST LAYER) | |
print(screenSize); // ! target box does not change with screen size | |
double screenCenterX = screenSize!.width / 2; | |
double screenCenterY = screenSize!.height / 2; | |
Rect boxRect = Rect.fromLTWH(screenCenterX - 75, screenCenterY - 75, 150, 150); | |
Paint boxPaint = Paint(); | |
// CHANGE TARGET BOX COLOUR CONDITIONALLY | |
if (hasPressed) { | |
boxPaint.color = Color(0xff00ff00); | |
} else { | |
boxPaint.color = Color(0xffffffff); | |
} | |
canvas.drawRect(boxRect, boxPaint); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment