Jump to content

scaled blitter bob


systemlord01
 Share

Recommended Posts

Hi,

I was very interested in the perfomance of the blitter but i ran into a problem.

First i load the asset (this is just one image with one frame) and then i make a blitter. But the dimensions of the image is to big. So i want to scale it before making it into a blitter.

I dont want to resize the original image to do this. Is there a way to accomplish this?

 

I am using pahser 3.15

Link to comment
Share on other sites

I understand this. Hence my question. If you have a sprite and you manipulate it to your needs. And then make a blitter object. You can spawn alot of Bobs (that are all the same).

Basicly you just do some pre-manipulation before turning a texture into a blitter. After turning it into a blitter you can not manipulate it anymore.

This technique would allow you to use Blitter much more flexibly

 

 

Link to comment
Share on other sites

For example

this.scene.load.image('arrow', 'assets/arrow.png');
const right: Phaser.GameObjects.Sprite = this.scene.add.sprite(x, y,'arrow');
const down: Phaser.GameObjects.Sprite = this.scene.add.sprite(x, y,'arrow');
down.setAngle(90);
const rightArrowBlitter = this.add.blitter(....,right) 
const downArrowBlitter = this.add.blitter(...,down) ) //we create the blitter from the manipulated sprite
rightArrowBlitter.create(....)
downArrowBlitter.create(....)
 
The blitters are fixed but we did not need to make a second asset for making a down arrow. We could do alle the existing manipulations (tint, angle, scale) before making non modifiable blitter.
 
This would enable alot of flexibility.
 
It should be possible since a blitter just uses the one instance to draw, this probably makes the rendering speed fast since there is only one instance of the texture. I only suggest a more flexible way to create this one instance. (this is an assumption)
 
I know it is possible in paper.js (where this is called a symbol).
 
Link to comment
Share on other sites

That’s missing the point of how the blitter object works internally. When you tint, scale or rotate a sprite the underlying texture is never changed at all. It’s modified by sending all that extra data to the shader. Blitters bypass this step entirely. They dump the raw texture data out directly.

If you want to scale the texture, or rotate it, do it in an art package, or don’t use a blitter.

Link to comment
Share on other sites

const downArrowBlitter = this.add.blitter(...,down) )

Could make a new texture with the transformations applied. It can make this new texture by passing through the shader one time and saving the result pixels into a new texture (i dont know if you guys use internal canvasses for this or just bit arrays). This new texture can then be used by the blitter.

Hence having the speed but also having  capabilty of transformation before making the blitter.

Of course i am not familiar with the internal code of phaser. But theoreticly this is certainly possible.

This is more like a feature request for you guys to considder. But for the moment i will try to scale the texture. 

 

Thanks you for taking the time to reply.

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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