如何在物质js的fromVertices中添加纹理?

时间:2018-07-09 12:55:33

标签: textures matterjs

var customOption= {
density: 0.2,
restitution: 0.8,
render: {
    sprite: {
        texture: './images/bowl.png',
        xScale: 1,
        yScale: 1
    }
  }
};



var ball= {
    density: 0.2,
    restitution: 0.8,
    render: {
        sprite: {
            texture: './images/football.png',
            xScale: 1,
            yScale: 1
        }
    }
};

var customShape = Vertices.fromPath('35 7 19 17 14 38 14 58 25 79 45 85 65 84 65 66 46 67 34 59 30 44 33 29 45 23 66 23 66 7 53 7');

var customBody = Bodies.fromVertices(80, 10, customShape, customOption);
var foot = Bodies.circle(380, 40, 50 / 2, ball);

customBody没有显示任何纹理,但是足球对象渲染得很好。

请告诉我我在哪里做错了。

0 个答案:

没有答案