Как сделать вращение объекта под действием силы тяжести, когда объект падает на склон.
Например. вот что я хочу, чтобы произошло:
Вот мой код:
this.box_speed++;
if(this.box_speed > 0){
//check ground
for (i = 0; i < this.box_speed; i++) {
if(!this.terrain_bmp.hitTest(new Rectangle(this.box.x,this.box.y + 20,10,1))){
this.box.y += 1;
}else{
this.box_speed = 0;
}
}
}else{
for (i = 0; i < Math.abs(this.box_speed); i++) {
if(!this.terrain_bmp.hitTest(new Rectangle(this.box.x,this.box.y,10,1))){
this.box.y -= 1;
}
else{
this.box_speed = 0;
}
}
}