Open ayushi15092002 opened 2 years ago
that would be really nice feature! i would love to add it to my game!
that might work
import 'package:flutter/material.dart';
void main() {
runApp(MyApp());
}
class MyPainter extends CustomPainter {
final Function(Offset) onRectClicked;
MyPainter({required this.onRectClicked});
@override
void paint(Canvas canvas, Size size) {
// Draw a rectangle
final rect = Rect.fromPoints(Offset(50, 50), Offset(200, 200));
final paint = Paint()..color = Colors.blue;
canvas.drawRect(rect, paint);
}
@override
bool shouldRepaint(covariant CustomPainter oldDelegate) {
return false;
}
@override
bool hitTest(Offset position) {
final rect = Rect.fromPoints(Offset(50, 50), Offset(200, 200));
if (rect.contains(position)) {
onRectClicked(position);
return true; // Consider the hit as handled
}
return false; // Consider the hit as not handled
}
}
class MyApp extends StatelessWidget {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
appBar: AppBar(
title: Text('Rect Click Example'),
),
body: CustomPaint(
painter: MyPainter(
onRectClicked: (position) {
print('You clicked inside the rect at $position');
},
),
),
),
);
}
}
Hi! Would it be possible to navigate to other screen on tapping of completed level and current level?
Thanks!