[]物理引擎中更换刚体贴图的方法
this.ball = Matter.Bodies.circle(400, 600,34,
{
//密度
density: 1,
//弹力
restitution:0.4,
container:this.ballBox,
render:
{
sprite:
{
texture: "comp/basketball.png",
xOffset: 34,
yOffset: 34,
}
}
});
我想通过代码随时更改这个刚体上的texture贴图,this.ball.render.sprite.texture="comp/2.png"这个方法只能在游戏刚开始时执行一遍,还有什么其他更换刚体贴图的方法么,那种可以随时更改的那种方法
{
//密度
density: 1,
//弹力
restitution:0.4,
container:this.ballBox,
render:
{
sprite:
{
texture: "comp/basketball.png",
xOffset: 34,
yOffset: 34,
}
}
});
我想通过代码随时更改这个刚体上的texture贴图,this.ball.render.sprite.texture="comp/2.png"这个方法只能在游戏刚开始时执行一遍,还有什么其他更换刚体贴图的方法么,那种可以随时更改的那种方法
要回复问题请先登录
1 个回复
渔歌
赞同来自:
刚体上的贴图只能在刚创建时设置一次,可以用这个方法改变