简体   繁体   English

Physics.js getTarget未定义

[英]Physicsjs getTarget is undefined

I'm trying to make a custom behavior and I'm not very familiar with physicsjs. 我正在尝试进行自定义行为,但是我对physicsjs不太熟悉。 According to the docs in github I'm supposed to use var bodies = this.getTargets(); 根据github中的文档,我应该使用var bodies = this.getTargets(); to iterate through the bodies , but I keep getting an undefined is not a function error. 遍历正文,但我不断得到undefined is not a function错误。 fiddle 小提琴

What am I doing wrong? 我究竟做错了什么?

Looks like the physicsjs version was 0.5.2 in the jsFiddle. 看起来jsFiddle中的physicsjs版本是0.5.2。 The method getTargets was only introduced in 0.6. 方法getTargets仅在0.6中引入。 Here's an updated version of the fiddle. 这是小提琴的更新版本。

http://jsfiddle.net/r8xum92m/3/ http://jsfiddle.net/r8xum92m/3/

also make sure to use .on() instead of .subscribe() now. 还请确保现在使用.on()而不是.subscribe()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM