-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
92 additions
and
14 deletions.
There are no files selected for viewing
Binary file not shown.
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
import 'package:flame/collisions.dart'; | ||
import 'package:flame/components.dart'; | ||
import 'package:flame/events.dart'; | ||
import 'package:flutter/material.dart'; | ||
import 'package:warioddly/utils/configs/text.dart'; | ||
|
||
|
||
class TouchableComponent extends PositionComponent with HoverCallbacks { | ||
|
||
TouchableComponent() : super( | ||
); | ||
|
||
|
||
@override | ||
Future<void> onLoad() async { | ||
super.onLoad(); | ||
add( | ||
TextComponent( | ||
text: 'Hello', | ||
textRenderer: TextConfig.renderer, | ||
) | ||
); | ||
} | ||
|
||
|
||
|
||
@override | ||
void onHoverEnter() { | ||
print('122'); | ||
super.onHoverEnter(); | ||
} | ||
|
||
} | ||
|
||
class MyShapeComponent extends PositionComponent | ||
with TapCallbacks, HoverCallbacks, GestureHitboxes { | ||
final ShapeHitbox hitbox; | ||
late final Color baseColor; | ||
late final Color hoverColor; | ||
|
||
MyShapeComponent({ | ||
required this.hitbox, | ||
super.position, | ||
super.size, | ||
super.angle, | ||
}) : super(anchor: Anchor.center); | ||
|
||
@override | ||
Future<void> onLoad() async { | ||
super.onLoad(); | ||
baseColor = Colors.white; | ||
hitbox.paint.color = baseColor; | ||
hitbox.renderShape = true; | ||
add(hitbox); | ||
} | ||
|
||
@override | ||
void onTapDown(TapDownEvent _) { | ||
removeFromParent(); | ||
} | ||
|
||
@override | ||
void onHoverEnter() { | ||
print('hover'); | ||
hitbox.paint.color = hitbox.paint.color; | ||
} | ||
|
||
@override | ||
void onHoverExit() { | ||
hitbox.paint.color = baseColor; | ||
} | ||
} |
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
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
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
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