Jump to content

Any suggestions about how to best draw lines with a texture?


dnassler
 Share

Recommended Posts

Hi everyone.... I'm trying to draw lines that look "nice"... i.e. I want my drawn/rendered lines to be based on an image (or sprite/image). At my current level of understanding of Phaser, all I can think to do is to use a texture (eg. mytexture = game.add.renderTexture('someimagekey',game.world.width,game.world.height) ) and render a sprite onto it that is stretched (so that it matches the length of the line I want drawn. This feels klunky (clunky?).  

 

Is there not some way of using the Line "class" to render beautiful lines with textures that I want?

Link to comment
Share on other sites

This might be the clunky version you describe, but depending on how many and what kind of lines you need, it might still be right for you.

 

For my tetris clone I used sprites as lines ( http://jppresents.net/games/fallingBlocks/ - see the lines outlining the game area).

 

They are made from sprites like this one:

stage_bottom.png

 

which are then given the appropriate width / height like this:

  sprite = stagegroup.create(offsetx, (field.height-2) * 32 + offsety, 'stage_bottom');  sprite.width = 320; 

It works quite well, but a box like in the game needs 8 sprites total. (because I don't want streched edges they need to be their own (unscaled) sprites)

 

I hope this helps (even if it's just reinforcing the clunky way),

 

If somebody has a better way, I am all ears tho.

 

JP

Link to comment
Share on other sites

 Share

  • Recently Browsing   0 members

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