Sign in to follow this  
Phempt

Texture

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);

Share this post


Link to post
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.

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

  • Recently Browsing   0 members

    No registered users viewing this page.