Jump to content

how to use transform in displayobject


vaibhavsilar
 Share

Recommended Posts

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!

Link to comment
Share on other sites

  • 1 year later...

@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;        
}

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...