-
Notifications
You must be signed in to change notification settings - Fork 29.7k
Description
I am making a game using Flutter, but I noticed something weird while trying to draw a sprite from a spritesheet, so I made an example to show the problem:
Lets say this image is a spritesheet, it is 64x128:
I split it in two and want to draw only the second part, I do it this way:
final src = Rect.fromLTWH(0, 64, 64, 64);
final dst = Rect.fromLTWH(0, y, 64, 64);
canvas.drawImageRect(testImage, src, dst, Paint());If then, I move this sprite through the canvas, by incrementing the value of y by 0.1 every frame, the last row of the first part is drawn.
It should not draw the last row of the first sprite, because I made explicity that I only want the second half of the image to be drawn.
I tried it on iOS and macOS and got the same problem.
I made a repository where you can run it and see this behavior.
https://github.com/lslv1243/draw_image_rect_bug
flutter doctor
[✓] Flutter (Channel unknown, 1.22.0-12.1.pre, on Mac OS X 10.15.6 19G2021, locale pt)
• Flutter version 1.22.0-12.1.pre at /Users/leonardosilva/development/flutter/flutter
• Framework revision 8b3760638a (4 weeks ago), 2020-09-15 17:47:13 -0700
• Engine revision 4654fc6cf6
• Dart version 2.10.0 (build 2.10.0-110.3.beta)
[!] Android toolchain - develop for Android devices (Android SDK version 29.0.3)
• Android SDK at /Users/leonardosilva/Library/Android/sdk
• Platform android-29, build-tools 29.0.3
• Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
! Some Android licenses not accepted. To resolve this, run: flutter doctor --android-licenses
[✓] Xcode - develop for iOS and macOS (Xcode 12.0)
• Xcode at /Applications/Xcode.app/Contents/Developer
• Xcode 12.0, Build version 12A7209
• CocoaPods version 1.8.4
[✓] Chrome - develop for the web
• Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome
[✓] Android Studio (version 4.0)
• Android Studio at /Applications/Android Studio.app/Contents
• Flutter plugin version 49.0.2
• Dart plugin version 193.7547
• Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6222593)
[✓] VS Code (version 1.50.0)
• VS Code at /Applications/Visual Studio Code.app/Contents
• Flutter extension version 3.15.0
[✓] Connected device (4 available)
• iPhone de Leonardo (mobile) • ac197a55a52fbad3d364054a4c99dbe29ed46b23 • ios • iOS 14.0
• macOS (desktop) • macos • darwin-x64 • Mac OS X
10.15.6 19G2021
• Web Server (web) • web-server • web-javascript • Flutter
Tools
• Chrome (web) • chrome • web-javascript • Google
Chrome 86.0.4240.75

