我正在尝试使用SpriteKit并创建一个弯曲关节,弯曲以允许另一个关节移动。问题在于,当我创建关节时,当我在屏幕上滑动以移动时,所有部件都旋转360度,因此没有固定的关节(即具有一定范围的移动的肘部)。我附上了我的一些代码 - 有些部分在我进行实验时被注释掉了。
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title></title>
<script src="https://code.jquery.com/jquery-1.12.4.js"></script>
<script type="text/javascript">
$(document).ready(function () {
$('.employee input[type="text"]').keypress(function (evt) {
var theEvent = evt || window.event;
var keyVal = theEvent.keyCode || theEvent.which;
var key = theEvent.keyCode || theEvent.which;
key = String.fromCharCode(key);
if (navigator.userAgent.toLowerCase().indexOf('firefox') > -1) {
if (key != " " && key != "(" && key != ")" && keyVal != 8 && keyVal != 37 && keyVal != 39 && keyVal != 46 && keyVal != 48) {
var regex = /[0-9]|\./;
if (!regex.test(key)) {
theEvent.returnValue = false;
if (theEvent.preventDefault) theEvent.preventDefault();
}
}
}
else {
if (key != "-") {
var regex = /[0-9]|\./;
if (!regex.test(key)) {
theEvent.returnValue = false;
if (theEvent.preventDefault) theEvent.preventDefault();
}
}
}
});
$('.employee input[type="text"]').keyup(function () {
var total_sum = 0;
var inputs = $(this).parents('.employee').find('input[type="text"]');
$.each(inputs, function (index, item) {
var thisValue = parseFloat($(item).val());
thisValue = isNaN(thisValue) ? 0 : thisValue;
if (index < inputs.length - 1)
if (this.name.indexOf('txtDeduction') > -1 || this.name.indexOf('txtAdvance') > -1)
total_sum -= thisValue;
else
total_sum += thisValue;
});
inputs.last().val(total_sum);
});
});
</script>
</head>
<body>
<div class="col-md-12">
<div ng-controller="customersCrtl">
<!-- Adjustment Code Start -->
<!-- Heading Data Start -->
<div class="row parts_title space_bottom" style="border-bottom:1px solid #ddd; padding-bottom:5px;">
<div class="col-xs-1 col-md-1" style="text-align:left !important;">#</div>
<div class="col-xs-2 col-md-2" style="text-align:left !important;">Employee#</div>
<div class="col-xs-2 col-md-2" style="text-align:left !important;">FullName</div>
<div class="col-xs-1 col-md-1">B.Salary</div>
<div class="col-xs-1 col-md-1">Advance</div>
<div class="col-xs-1 col-md-1">Rec.Comm</div>
<div class="col-xs-1 col-md-1">Sal.Comm</div>
<div class="col-xs-1 col-md-1">Deduction</div>
<div class="col-xs-1 col-md-1">Adjustment</div>
<div class="col-xs-1 col-md-1">Total</div>
</div>
<!-- Heading Data End -->
<div class="employee row space_bottom">
<div class="col-xs-1 col-md-1"><input name="checked1" checked="" type="checkbox"></div>
<div class="col-xs-2 col-md-2">E17-00001</div>
<div class="col-xs-2 col-md-2">Employee Name 1</div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="50000" name="txtMonthlyRate1" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0" name="txtAdvance1" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="35" name="txtRecovery1" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="2350" name="txtSales1" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0.00" name="txtDeduction1" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0.00" name="txtAdjustment1" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="sumtotal form-control input-sm" value="52385" name="txtTotal1" id="sumtotal" type="text"></div>
</div>
<div class="employee row space_bottom">
<div class="col-xs-1 col-md-1"><input name="checked2" checked="" type="checkbox"></div>
<div class="col-xs-2 col-md-2">E17-00002</div>
<div class="col-xs-2 col-md-2">Employee Name 2</div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="10000" name="txtMonthlyRate2" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0" name="txtAdvance2" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0" name="txtRecovery2" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0" name="txtSales2" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0.00" name="txtDeduction2" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="form-control input-sm" value="0.00" name="txtAdjustment2" type="text"></div>
<div class="col-xs-1 col-md-1"><input class="sumtotal form-control input-sm" value="10000" name="txtTotal2" id="sumtotal" type="text"></div>
</div>
<!-- Adjustment Code End -->
</div>
</div>
</body>
</html>
答案 0 :(得分:0)
根据此处的文件:https://developer.apple.com/reference/spritekit/skphysicsjointpin
您可以通过关节的属性设置针关节的旋转限制:
var shouldEnableLimits: Bool
一个布尔值,指示是否 销钉接头的旋转受限于特定的数值范围。v
ar lowerAngleLimit: CGFloat
引脚允许的最小角度 关节,弧度。
var upperAngleLimit: CGFloat
引脚允许的最大角度 关节,弧度。