Phempt Posted November 29, 2014 Share Posted November 29, 2014 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); Quote Link to comment Share on other sites More sharing options...
Phempt Posted November 29, 2014 Author Share Posted November 29, 2014 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. Quote Link to comment Share on other sites More sharing options...
Phempt Posted December 2, 2014 Author Share Posted December 2, 2014 Any idea? Quote Link to comment Share on other sites More sharing options...
enpu Posted December 2, 2014 Share Posted December 2, 2014 Make TilingSprite using shape's dimensions and then update it's position using body's position. Quote Link to comment Share on other sites More sharing options...
Phempt Posted December 2, 2014 Author Share Posted December 2, 2014 I'll try thank you Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.