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

add.tileSprite in new version is not convenient to use #4073

Closed
jcyuan opened this issue Sep 28, 2018 · 3 comments
Closed

add.tileSprite in new version is not convenient to use #4073

jcyuan opened this issue Sep 28, 2018 · 3 comments

Comments

@jcyuan
Copy link
Contributor

jcyuan commented Sep 28, 2018

in previous version I can pass width/height with 0 to add.tileSprite add.tileSprite(x, y, w, h, atlas, frame);

but in 3.13 pass width/height with 0 will cause error because the class wants to fetch imageData from the canvas.

my purpose is to create a tileSprite and use its frame to init the width / height:

const spr = this.scene.add.tileSprite(0, 0, 0, 0, "atlas", "ground");
spr.width = spr.frame.width;
spr.height = spr.frame.height;

this works in previous verison but 3.13.
the problems:

  1. can't pass width/height as 0
  2. when pass width/height as 1 and finally created a tileSprite, but you will find both spr.frame.width, spr.frame.height are 0 which does not exist in previous version.
@jcyuan jcyuan changed the title add.tileSprite in new version is not convenience to use add.tileSprite in new version is not convenient to use Sep 28, 2018
@jcyuan
Copy link
Contributor Author

jcyuan commented Sep 28, 2018

and actually.... the image added to scene is cut, I don't know why....

it seems webgl viewport does not fit to the stage and is placed to the left bottom corner.

this does not exist in 3.12.0

@photonstorm
Copy link
Collaborator

If you now pass zero as either the width or height of a TileSprite it will use the size of the texture frame as the width and height. If you want to change it like you were doing before, you need to get the size from the displayTexture and displayFrame properties, not texture and frame which just refer to the canvas the texture has been drawn to.

@jcyuan
Copy link
Contributor Author

jcyuan commented Oct 8, 2018

got it, thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants