Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Handling Pixel Images #42

Open
sy318 opened this issue Apr 14, 2024 · 1 comment
Open

Handling Pixel Images #42

sy318 opened this issue Apr 14, 2024 · 1 comment
Labels
help wanted Extra attention is needed question Further information is requested

Comments

@sy318
Copy link
Collaborator

sy318 commented Apr 14, 2024

Overall

We understand that pixel images need to be scaled by whole numbers to prevent distortion. Is there a method to load pixel images with Flame Sprites that ensures they are scaled by whole numbers?

As shown in the picture, the ratio of one pixel is broken, so the thickness of the line is not constant.

Examples

KakaoTalk_20240415_030507666

@sy318 sy318 added help wanted Extra attention is needed question Further information is requested labels Apr 14, 2024
@eunjijeon11
Copy link
Collaborator

eunjijeon11 commented Apr 14, 2024

Below is the code we use currently to load the character image.
You can find this code here.

const double CHARACTER_SIZE_X = 100 * 1.4;
const double CHARACTER_SIZE_Y = 128 * 1.4;

class MyPlayer extends SpriteAnimationGroupComponent<CharacterState> {

  late final Vector2 screensize;

  late Sprite idle;
  late Sprite walk1;
  late Sprite walk2;

  MyPlayer(this.uid, this.screensize, this.joystick)
      : super(
            size: Vector2(CHARACTER_SIZE_X * 1.w, CHARACTER_SIZE_Y * 1.w),
            anchor: Anchor.center,
            position: screensize * 0.5) {
    moveForce = Vector2.zero();
  }

  @override
  FutureOr<void> onLoad() async {
    idle = await Sprite.load("characters/${role.code}_idle.png");
    walk1 = await Sprite.load("characters/${role.code}_walk1.png");
    walk2 = await Sprite.load("characters/${role.code}_walk2.png");

    // ... (omit) ...

    return super.onLoad();
  }

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants