Jump to content

Scaling sprites at default height and width


Sahil
 Share

Recommended Posts

Hi,

I was working on some effect using rectangles using graphics object. @OSUblake Suggested me that using Sprites with tint would give me be better performance. So I decided to replace my graphics object with sprites. Though scaling them and positioning them to scale from center gives me some strange behavior which is because I guess that sprites are calculated based on canvas dimensions.

Then I removed the height and width from sprite and they defaulted to 10x10 rectangle that ignores the dimension of canvas. So I can work with it and avoid doing calculations to position all the sprites.

https://codepen.io/Sahil89/pen/PemgeO?editors=0010

Following are my questions

1. Is it safe to assume that in all browser environments sprites will default to 10x10 dimensions?

2. How much difference does it make in performance to use sprites instead of graphics object while am using 1000-1500 rectangles? is it significant?

Link to comment
Share on other sites

which is because I guess that sprites are calculated based on canvas dimensions.

Make a fiddle.

1. Yes, PIXI.Texture.WHITE size is 10x10. 

2. Graphics will automatically be rendered as sprites with whtie texture if they are rectangles. If they aren't , you can have only 50 sprites on mobiles , 200 for PC, everything else starts slowing down because of excessive drawcalls.

Link to comment
Share on other sites

Quote

Make a fiddle.

Don't know what was happening but when I was creating this question, my sprite was getting stretched if I change canvas dimension. Doesn't happen anymore, I must have been doing something wrong.

BTW in previous thread you mentioned you write articles, can you post link to your blog?

Thanks

Link to comment
Share on other sites

3 hours ago, ivan.popelyshev said:

50 sprites on mobiles , 200 for PC, everything else starts slowing down because of excessive drawcalls.

 ??? here 400 spine animation with pixi without slowing.

https://youtu.be/8oGkRMTnReQ

200 for pc ?? I would say rather between 600 and 800

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Loading...
 Share

  • Recently Browsing   0 members

    • No registered users viewing this page.
×
×
  • Create New...