Jump to content

Drawing sprite from coords to coords


Virgil
 Share

Recommended Posts

Hi guys,

I want to draw a sprite (sort of a decorative line png, like 5 pixels wide and 200 pixels in height) from one coordinate to the another. 

So it needs to scale and rotate. 

Maybe if I set the pivot or anchor point (whats the difference?) I want something like drawSpriteToCoords(xSource, ySource, xDestination, yDestination)

Thanks!

example.png

line-2.png

Link to comment
Share on other sites

May the Math be with you!

Also, dont forget that "height = xxx" is actually setting "scale.y = xxx / texture.height" :)

var texture = new PIXI.Texture(brushTexture, brushTexture.frame.clone());
//now we have new texture!

var sprite = new PIXI.Sprite(texture);

...

//sprite.height = ..
texture.frame.height = Math.min(Math.sqrt(dx*dx+dy*dy), brushTexture.height);
texture._updateUvs();

 

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