mirror of
https://github.com/flame-engine/flame.git
synced 2025-11-01 10:38:17 +08:00
All components must call super
This commit is contained in:
@ -16,10 +16,10 @@ class MyGame extends BaseGame with TapDetector {
|
||||
}
|
||||
|
||||
@override
|
||||
void onTapUp(details) {
|
||||
void onTapUp(TapUpDetails details) {
|
||||
square.addEffect(MoveEffect(
|
||||
path: [
|
||||
details.localPosition.toVector2().clone(),
|
||||
details.localPosition.toVector2(),
|
||||
Vector2(100, 100),
|
||||
Vector2(50, 120),
|
||||
Vector2(200, 400),
|
||||
|
||||
@ -37,6 +37,7 @@ class Player extends Component implements JoystickListener {
|
||||
|
||||
@override
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
if (_move) {
|
||||
moveFromAngle(dt);
|
||||
}
|
||||
|
||||
@ -590,6 +590,7 @@ class TrafficLightComponent extends Component {
|
||||
|
||||
@override
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
colorChangeTimer.update(dt);
|
||||
}
|
||||
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import 'dart:ui';
|
||||
|
||||
import 'package:flutter/painting.dart';
|
||||
import 'package:meta/meta.dart';
|
||||
|
||||
import '../effects/effects.dart';
|
||||
import '../extensions/vector2.dart';
|
||||
@ -19,6 +20,7 @@ abstract class Component {
|
||||
/// The time [t] in seconds (with microseconds precision provided by Flutter) since the last update cycle.
|
||||
/// This time can vary according to hardware capacity, so make sure to update your state considering this.
|
||||
/// All components on [BaseGame] are always updated by the same amount. The time each one takes to update adds up to the next update cycle.
|
||||
@mustCallSuper
|
||||
void update(double dt) {
|
||||
_effects.forEach((e) => e.update(dt));
|
||||
_effects.removeWhere((e) => e.hasFinished());
|
||||
|
||||
@ -65,6 +65,7 @@ class JoystickComponent extends JoystickController {
|
||||
|
||||
@override
|
||||
void update(double t) {
|
||||
super.update(t);
|
||||
directional?.update(t);
|
||||
actions?.forEach((action) => action.update(t));
|
||||
}
|
||||
|
||||
@ -35,6 +35,7 @@ class ParticleComponent extends Component {
|
||||
/// Passes update chain to child [Particle].
|
||||
@override
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
particle.update(dt);
|
||||
}
|
||||
}
|
||||
|
||||
@ -182,10 +182,6 @@ abstract class PositionComponent extends Component {
|
||||
canvas.restore();
|
||||
}
|
||||
|
||||
@mustCallSuper
|
||||
@override
|
||||
void update(double dt) => super.update(dt);
|
||||
|
||||
void _renderChild(Canvas canvas, Component c) {
|
||||
if (!c.loaded()) {
|
||||
return;
|
||||
|
||||
@ -25,7 +25,4 @@ class SpriteBatchComponent extends Component {
|
||||
paint: paint,
|
||||
);
|
||||
}
|
||||
|
||||
@override
|
||||
void update(double t) {}
|
||||
}
|
||||
|
||||
@ -10,7 +10,10 @@ class TimerComponent extends Component {
|
||||
TimerComponent(this.timer);
|
||||
|
||||
@override
|
||||
void update(double dt) => timer.update(dt);
|
||||
void update(double dt) {
|
||||
super.update(dt);
|
||||
timer.update(dt);
|
||||
}
|
||||
|
||||
@override
|
||||
void render(Canvas canvas) {}
|
||||
|
||||
Reference in New Issue
Block a user