Jump to content

Texture


Phempt
 Share

Recommended Posts

Hello guys, is it possible to color a body shape with a repeatable texture? Something like:

var floorBody = new game.Body({            position: {                x: game.system.width / 2,                y: game.system.height - 35            },            collisionGroup: 1        });                /* GAME STANDARD SHAPES & BODIES */        var floorShape = new game.Rectangle(game.system.width, 70);        floorShape.TEXTURE = new game.sprite('env/black.jpg'); //something like this        floorBody.addShape(floorShape);        this.world.addBody(floorBody);
Link to comment
Share on other sites

I used this:

floorSprite = new game.Sprite('env/black.png');        floorSprite.width = floorShape.width;        floorSprite.height = floorShape.height;        floorSprite.position.x = floorBody.position.x;        floorSprite.position.y = floorBody.position.y;        floorSprite.anchor.set(0.5,0.5);        floorSprite.addTo(game.scene.bgContainer);        game.scene.addObject(floorSprite);

is there a better way? because this method stretch a sprite to fill a shape, but it's not a repeatable texture.

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