Показать сообщение отдельно
  #2 (permalink)  
Старый 14.04.2014, 17:00
Профессор
Отправить личное сообщение для jsnb Посмотреть профиль Найти все сообщения от jsnb
 
Регистрация: 15.03.2014
Сообщений: 561

Так там же синтаксис не такой...
Вот так примерно должен был выглядеть твой код:
this.on("start", function(){
 this.thrusters.top(true); 
});

this.on('sensor:top', function(contact) {
  this.thrusters.right(true);
  this.thrusters.bottom(false);
});

this.on('sensor:right', function(contact) {
  this.thrusters.bottom(true);
  this.thrusters.left(false);
});

this.on('sensor:bottom', function(contact) {
  this.thrusters.left(true);
  this.thrusters.top(false);
});

this.on('sensor:left', function(contact) {
  this.thrusters.top(true);
  this.thrusters.right(false);
});

Хотя там всё равно ошибка в логике работы. И там же написано: "The value of contact will be true when contact has been made and false when it has been lost." Т.е. можно детекстиль отрыв от поверхности через проверку contact на false.

Последний раз редактировалось jsnb, 14.04.2014 в 17:06.
Ответить с цитированием