OpacityEffect is not working on TextComponent
It should work as expected when used with component that has mixin HasPaint
import 'package:flame/components.dart';
import 'package:flame/effects.dart';
import 'package:flame/game.dart';
import 'package:flame/input.dart';
import 'package:flutter/material.dart';
class OpacityEffectGame extends FlameGame {
SpriteComponent sprite;
@OverRide
Future onLoad() async {
await super.onLoad();
final textConfig =
TextPaint(config: TextPaintConfig(color: Colors.white, fontSize: 35));
final newStageComponent = TextEffectComponent('Stage',
config: textConfig, position: Vector2(size.x/2, size.y / 2))
..anchor = Anchor.center;
await newStageComponent.add(
OpacityEffect(
opacity: 0,
duration: 0.5,
isInfinite: true,
isAlternating: true,
));
await add(newStageComponent);
}
}
class TextEffectComponent extends TextComponent with HasPaint {
TextEffectComponent(String text,{Vector2 position,TextRenderer config}) : super(text, position: position, textRenderer: config);
}
Output of: flutter doctor -v
Flutter (Channel stable, 2.5.2, on macOS 11.6 20G165 darwin-x64, locale en-IN)
• Flutter version 2.5.2 at /Users/jeevanson.m/Documents/Work/Flutter/flutter
• Upstream repository https://github.com/flutter/flutter.git
• Framework revision 3595343e20 (10 days ago), 2021-09-30 12:58:18 -0700
• Engine revision 6ac856380f
• Dart version 2.14.3
[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.3)
• Android SDK at /Users/jeevanson.m/Library/Android/sdk
• Platform android-30, build-tools 30.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
• All Android licenses accepted.
[✓] Xcode - develop for iOS and macOS
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 13.0, Build version 13A233
• CocoaPods version 1.10.1
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.2)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/9212-flutter
• Dart plugin can be installed from:
🔨 https://plugins.jetbrains.com/plugin/6351-dart
• Java version OpenJDK Runtime Environment (build 11.0.8+10-b944.6916264)
[✓] Connected device (2 available)
• sdk gphone x86 arm (mobile) • emulator-5554 • android-x86 • Android 11 (API 30) (emulator)
• Chrome (web) • chrome • web-javascript • Google Chrome 94.0.4606.71
• No issues found!
Flame version
flame: ^1.0.0-releasecandidate.14
Enter log information in this code block
Pay now to fund the work behind this issue.
Get updates on progress being made.
Maintainer is rewarded once the issue is completed.
You're funding impactful open source efforts
You want to contribute to this effort
You want to get funding like this too