Box2djs,JS 物理引擎 - 为球对象设置背景图像?
在这里使用 Box2djs 插件: http://www.crackin.com/dev/mms/physicals/
..我想做的就是用图像纹理填充球对象。我希望它像设置 css 值一样简单,但我似乎做得不对,因为没有一个标准背景相关的 css 规则会改变球。使用 math.random,我可以创建 5 个不同的类名称来应用于每个球,以创建不同的纹理对象。
下面是它现在的样子,与我可以使用图像使它们看起来像的东西相比: M&M 模拟图像
这是我的物理引擎的特定构建正在用这个... github.com/hrj/box2d-js ...它使用 jQuery 而不是 Prototype。
Working with the Box2djs plugin here:
http://www.crackin.com/dev/mms/physics/
... and all I'm trying to do is fill the ball objects with an image texture. I was hoping it was as simple as setting a css value, but I don't seem to be doing it right as none of the standard background related css rules change the balls. Using a math.random I could create 5 distinct class names to apply to each ball to create the different textured objects.
Here's an example of what it looks like now, compared to something I could make them look like using images:
M&M Mock Image
This is the specific build of the physics engine I'm using this ...
github.com/hrj/box2d-js ... which is using jQuery instead of Prototype.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
我经常使用 Box2DJS,并且认为我已经找到了实现几乎任何东西所需的一切(例如碰撞检测挂钩等)。下面是我编写的一段代码,用于集成框或圆形图像来代替框或圆形对象:
I've been playing with Box2DJS a lot and think I've found everything I need to implement it for almost anything (e.g. collision detection hooks, etc). Here is a snippet of code that I wrote to integrate a box or circle image in place of a box or circle object: