为什么这个输出不一致?

时间:2018-04-08 07:11:36

标签: ios xcode sprite-kit skphysicsbody skphysicsworld

override func didMove(to view: SKView) {
    ball=SKShapeNode.init(rectOf: CGSize.init(width: 10, height: 10))
    ball.lineWidth=0
    ball.physicsBody=SKPhysicsBody.init(rectangleOf: CGSize.init(width: 10, height: 10))

    ball.position=CGPoint.init(x: 0, y: 0)

    self.addChild(ball)
    ball.physicsBody!.velocity=CGVector.init(dx: 0, dy: 0)

    self.physicsWorld.gravity=CGVector.init(dx: 0, dy: -0.01)
}

override func didFinishUpdate() {
    print((-ball.physicsBody!.velocity.dy)/((-ball.position.y)/(-ball.physicsBody!.velocity.dy/2)))
}

输出: 1.4310210438517 1.42473254886035 1.42380975809209 1.42285065872957 1.42185899338757 1.42083705265364 1.41978773377494 1.41871330485672 1.41761550240789 1.41649680153093 1.41535815092362 1.41420155874539 1.41302819426671 1.41183908563227 1.41063608544617 1.40941939437473 1.40819085763207 1.4069507476679 1.40569994613022 1.40443912710566 1.40316889163272 1.40189032668562 1.40060389047008 1.39930981002438 1.3980086177394 1.39670135724005 1.39538822941222 1.3940696854372 1.3927454368284 1.39141694745025 1.39008355320803 1.38874607529963 1.387404633016 1.38605934341604 1.38471084197874 1.3833595145688 1.38200513075583 1.3806482372776 1.37928863118993 1.37792691042815 1.37656326127297 1.37519711050934 1.37382946542547 1.37245997303348 1.37108918198904 1.36971714713335 1.36834384140732 1.36696932521041 1.36559404986317 1.36421788447531 1.3628405907902 1.3614627199032 1.36008426490743 1.3587055498073 1.3573263382028 1.35594647229548 1.35456664886424 1.35318668984808 1.35180648065711 1.35042632284601 1.34904599525735 1.3476660886723 1.34628637120676 1.34490655007056 1.34352717817481 1.34214825516409 1.34076956266992 1.33939116967523 1.33801325532258 1.3366358790194 1.33525901699307 1.33388303415708 1.33250717522619 1.33113215378044 1.32975801635423 1.32838414421357 1.32701111306219 1.32563933830281 1.32426758905413 1.3228970477821 1.32152737899811 1.32015835702641 1.3187906447746 1.3174239100656 1.31605782496892 1.31469279153619 1.31332872547715 1.31196566667412 1.31060364476174 1.30924280705312 1.30788285505249 1.30652415898416 1.30516641633863 1.30381010280519 1.30245469794886 1.30110057057794 1.29974752918125 1.29839562271435 1.29704518712955 1.29569584202635 1.29434782499582 1.29300085935135 1.29165497307993 1.29031060050431 1.28896738052348 1.28762545419971 1.28628464369092 1.28494545219929 1.28360736794894 1.28227069316718 1.28093517207214 1.27960129017998 1.27826863586409 1.27693730635726 1.27560735784953 1.27427880765903 1.2729517437664 1.27162582047838 1.27030163963059 1.26897863552402 1.2676570782965 1.26633695769264 1.26501799990428 1.26370099771256 1.26238510002457 1.26107087114903 1.25975778144494 1.25844630568929 1.25713605058639 1.25582726549303 1.2545199510486 1.2532142985786 1.25190968787039 1.2506070928494 1.24930578236314 1.24800566643984 1.24670741716467 1.2454103275286 1.24411490152722 1.24282093247028 1.24152837796215 1.24023751277911 1.23894797792525 1.23765978926466 1.23637336835834 1.23508821404541 1.23380454464686 1.23252247410288 1.23124185212043 1.22996280521175 1.22868503567403 1.22740886288384 1.22613428500731 1.22486131825241 1.22358986779858 1.22231986387838 1.22105136126329 1.21978432499609 1.21851880703641 1.21725460180433 1.21599221524688 1.21473144011458 1.21347187973796 1.21221411146497 1.21095777303452 1.2097027190479 1.20844931114563 1.20719747867042 1.20594738165392 1.20469844572283 1.2034511819688 1.20220555722454 1.20096119970216 1.19971849488758 1.1984772649706 1.19723788720658 1.19599980598168 1.194763183395 1.19352817987756 1.19229471711091 1.19106281527165 1.18983226091906 1.18860334858804 1.18737598223614 1.18615020022484 1.18492615800994 1.18370326664557 1.1824821901473 1.18126221705299 1.1800440041251 1.17882733526295 1.17761200545948 1.17639817230099 1.17518575323393 1.17397537905562 1.17276636590195 1.17155910283505 1.17035303750097 1.16914878960782 1.16794592580321 1.16674436837339 1.16554449620998 1.16434611669584 1.1631490344224 1.16195351186009 1.16075959046708 1.15956728967661 1.15837609488107 1.1571864907997 1.1559983887768 1.15481193627464 1.15362705846645 1.1524435643032 1.15126160240228 1.15008141924748 1.14890240830198 1.14772491731971 1.1465489947245 1.14537455084554 1.14420142232554 1.14302994693818 1.14185984410365 1.14069116689079 1.13952382707432 1.13835806176524 1.13719401276923 1.13603119917212 1.13486985652885 1.13370992203216 1.13255183141009 1.13139511085995 1.13023990357584 1.12908620389238 1.127934266822 1.126783543704 1.1256342626674 1.12448633280742 1.12333992783117 1.12219475935545 1.1210509691241 1.11990897331472 1.11876840125289 1.11762892348344 1.11649134150144 1.11535498031714 1.11422009335586 1.11308654958959 1.11195460207686 1.11082404304846 1.10969508451292 1.10856755814052 1.10744133760351 1.10631663345205 1.1051932802126 1.10407148525381 1.10295093961722 1.10183185080508 1.10071442270647 1.09959823753615 1.09848349978608 1.09737027246644 1.09625821403253 1.09514770757884 1.09403870386851 1.09293104312613 1.0918246789736 1.09071980965244 1.08961649895875 1.08851430175504 1.08741383110463 1.08631497271992 1.08521733042771 1.08412108230306 1.08302626380586 1.08193282975574 1.08084107974195 1.07975033034813 1.07866112950884 1.07757348060101 1.07648712156108 1.0754020108205 1.07431844438794 1.07323621143538 1.07215527155697 1.07107586823756 1.0699979588389 1.06892133623536 1.06784607539401 1.06677218690519 1.06569958056103 1.06462821768929 1.06355833417498 1.06249010324542 1.06142299918557 1.06035736544289 1.05929294551874 1.05823007898104 1.0571685661552 1.05610852822212 1.05504950454562 1.05399209425966 1.05293604546843 1.05188121989181 1.05082789194855 1.04977581929628 1.04872512353203 1.04767566157051 1.04662780743601 1.04558116976211 1.04453571578353 1.04349166441752 1.04244907842211 1.04140792198026 1.0403681047728 1.03932955180006 1.03829232624135 1.03725648956656 1.03622182002787 1.03518841844442 1.03415660504928 1.03312590046257 1.03209666172883 1.03106879877476 1.03004209731434 1.02901676418034 1.0279929134985 1.02697007626195 1.02594874798404 1.02492860655008 1.02391005487805 1.0228924850453 1.02187629986849 1.02086155454579 1.01984801790196 1.01883600167827 1.01782510708346 1.01681555811883 1.01580715778041 1.0148003248251 1.01379450083001 1.01279018517347 1.01178720777491 1.01078553947683 1.00978520974656 1.00878599465751 1.007788142903 1.00679135202765 1.00579594856255 1.00480168967828 1.00380878239448 1.00281723760485 1.00182704655719 1.00083797047239 0.999850118887215 0.998863616922139 0.997878303325356 0.996894477401935 0.995911712883748 0.994930457161549 0.993950227008096 0.992971511393131 0.991993902711504 0.99101749459299 0.990042406525832

1 个答案:

答案 0 :(得分:0)

刚刚找到确定空气摩擦的线性阻尼,输出在设定为零后变得一致