javascript - 在javascript中落在另一个对象上后旋转的对象
问题描述
当物体落在斜坡上时,如何利用重力旋转物体。
例如。这是我想要发生的事情:
这是我的代码:
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;
}
}
}
解决方案
推荐阅读
- c - C递归动态规划为什么要从最小值开始?
- html - 如何根据 Angular 中的条件隐藏和显示弹出对话框?
- swift - UICollectionViewCell 无法出列同类视图:带有标识符的 UICollectionElementKindCell
- arrays - 将数组元素与哈希键进行比较并将哈希值附加到数组
- scala - 火花更改 DF 模式列从点重命名为下划线
- powershell - 互斥开关参数
- firebase - 我如何从实时 Firebase 数据库中获取这些数据并添加到列表中?
- c# - wpf listview - 显示真实姓名而不是id
- javascript - 难以从异步函数返回值
- arrays - 具有索引值的序数集的数组?