Sign in to follow this  
vaibhavsilar

how to use transform in displayobject

Recommended Posts

Hello,

 

I want to use setTransform method of canvas in pixijs.

Is there any interface in pixijs to apply this concept.

 

I have tried implementing like this:

 

displayObj.localTransform = [1, 1, 1, 1, 0, 0];

 

but its not working. Please suggest.

 

Thanks

vbh

 

 

Share this post


Link to post
Share on other sites

hello!

Best to override the updateTransform - as at the moment the skews are not taken into account with pixi..

SkewableSprite.updateTransform = function(){	// TODO OPTIMIZE THIS!! with dirty		this.localTransform[0] = this.scale.x//this._cr * this.scale.x;	this.localTransform[1] = Math.tan(this.skew) * this.scale.y;// -this._sr * this.scale.y	this.localTransform[3] = 0//Math.tan(0.5);//this._sr * this.scale.x;	this.localTransform[4] = this.scale.y//this._cr * this.scale.y;			///AAARR GETTER SETTTER!		this.localTransform[2] = this.position.x;	this.localTransform[5] = this.position.y;		// TODO optimize?	mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform);	this.worldAlpha = this.alpha * this.parent.worldAlpha;		}

hope this helps!

Share this post


Link to post
Share on other sites

@Mat Groves

can you show me how an example on how to skew a image using phaser.js/pixi.js
 

using your example

SkewableSprite.updateTransform = function()
{
    // TODO OPTIMIZE THIS!! with dirty
    
    
this.localTransform[0] = this.scale.x//this._cr * this.scale.x;
    this.localTransform[1] = Math.tan(this.skew) * this.scale.y;// -this._sr * this.scale.y
    this.localTransform[3] = 0//Math.tan(0.5);//this._sr * this.scale.x;
    this.localTransform[4] = this.scale.y//this._cr * this.scale.y;
    
        
///AAARR GETTER SETTTER!
    
    
this.localTransform[2] = this.position.x;
    this.localTransform[5] = this.position.y;
    
    
// TODO optimize?
    mat3.multiply(this.localTransform, this.parent.worldTransform, this.worldTransform);
    this.worldAlpha = this.alpha * this.parent.worldAlpha;        
}

Share this post


Link to post
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...
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.