- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
我正在尝试制作一个类似带有扫动指针的时钟的东西。
我从 NSDate
中提取 session 记录。
然后稍微计算一个弧度值并找到我的 Sprite 在 1 分钟内应该移动到的 XY 位置,
然后在下一分钟开始时,我计算我的 Sprite 在该分钟内应该移动到的下一个 XY 位置。
所以我在更新函数中有这些代码
//Get Current Minute
var currentTime = NSDate();
var nowCal = NSCalendar(calendarIdentifier: NSCalendar.Identifier.ISO8601)
var currMin = nowCal?.component(.minute, from: currentTime as Date)
//Print current minute
print(currMin)
// slicing the circle into 60 segments and getting which angle in radians the sprite should move to in the next min
var minAng = (2*CGFloat.pi)/60 * CGFloat(currMin!)
//calculating point on the circle where the sprite should move to in the next min
var newPt = CGPoint(x: (300 * cos(minAng)), y: -(300 * sin(minAng)))
//print out where the sprite currently is and where it should move to
print(hand.position)
print(newPt)
//move the sprite to the new location over 60 seconds, making sure the movement is linear
let moveHand = SKAction.move(to: newPt, duration: 60)
moveHand.timingMode = SKActionTimingMode.linear
hand.run(moveHand)
//move another placeholder sprite to the final destination instantly to visualise movment by waiting for the moving sprite.
handToBe.run(SKAction.move(to: newPt, duration: 0))
假设我理解正确,它应该在 1 分钟内移动通过该段,在需要移动到下一个段之前到达该段的末尾。
但是,我的 Sprite 在需要移动到下一个片段之前从未到达片段的末尾。打印输出显示它总是太慢。
对于 SKAction.move(to:)
有什么我不理解的地方,或者我的逻辑在这个例子中有缺陷吗?
最佳答案
尝试从 update
函数中删除代码,然后在您自己调用的函数中运行它。 update
每帧都会被调用,所以 Sprite 开始移动,然后下一帧它被告知移动到另一个位置,所以它现在有两个移动 Action 需要同时运行。之后的帧有 3 个移动 Action 需要运行,等等。这可能意味着它永远不会真正到达其第一个预期位置,因为同时影响它的其他移动 Action 。
关于ios - SKAction Moveto 没有在持续时间内完成?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45018978/
我正在使用 Gunicorn 为 Django 应用程序提供服务,它工作正常,直到我将其超时时间从 30 秒更改为 900000 秒,我不得不这样做,因为我有一个用例需要上传和处理一个巨大的文件(过程
我有一个带有非常基本的管道的Jenkinsfile,它可以旋转docker容器: pipeline { agent { dockerfile { args '-u root' } } stag
在学习 MEAN 堆栈的过程中,我遇到了一个问题。每当我尝试使用 Passport 验证方法时,它都不会返回任何响应。我总是收到“localhost没有发送任何数据。ERR_EMPTY_RESPONS
在当今的大多数企业堆栈中,数据库是我们存储所有秘密的地方。它是安全屋,是待命室,也是用于存储可能非常私密或极具价值的物品的集散地。对于依赖它的数据库管理员、程序员和DevOps团队来说,保护它免受所
是否可以创建像图片上那样的边框?只需使用 css 边框属性。最终结果将是没 Angular 盒子。我不想添加额外的 html 元素。我只想为每个 li 元素添加 css 边框信息。 假设这是一个 ul
我是一名优秀的程序员,十分优秀!