作者热门文章
- html - 出于某种原因,IE8 对我的 Sass 文件中继承的 html5 CSS 不友好?
- JMeter 在响应断言中使用 span 标签的问题
- html - 在 :hover and :active? 上具有不同效果的 CSS 动画
- html - 相对于居中的 html 内容固定的 CSS 重复背景?
当我将 Sprite (在本例中为箭头)从一个父级(场景)移动到另一个父级(目标,场景中的 Sprite )时,箭头将被缩放并改变其大小。我怎样才能避免它?我希望箭头保持其大小。
这是我在向场景添加新箭头时使用的代码:
func newArrow() {
let arrow = SKSpriteNode(imageNamed: "arrow1")
let arrowTexture = SKTexture(imageNamed: "arrow1")
arrow.position = CGPoint.zero
arrow.physicsBody = SKPhysicsBody(texture: arrowTexture, size: arrowTexture.size())
arrow.physicsBody?.isDynamic = true
arrow.physicsBody?.allowsRotation = true
arrow.physicsBody?.affectedByGravity = false
arrow.physicsBody?.friction = 0.2
arrow.physicsBody?.restitution = 0.2
arrow.physicsBody?.linearDamping = 0.1
arrow.physicsBody?.velocity = CGVector(dx: 0, dy: 0)
self.addChild(arrow)
}
这是我将箭头移动到另一个父级时使用的代码:
func arrowCollideWithTarget() {
arrow.move(toParent:target!)
}
最佳答案
感谢@E.Huckabee,我能够解决这个问题。我所做的只是设定目标的规模 - 你可以通过两种方式来做到这一点:1. 在“属性检查器”中更改 Sprite 的比例2.来自代码 - sprite.xScale = 1.0 sprite.yScale = 1.0
关于swift - 在 Swift 4.2 中 - 如何在移动后保持 Sprite 大小(toParent : newParent),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/52682415/
当我将 Sprite (在本例中为箭头)从一个父级(场景)移动到另一个父级(目标,场景中的 Sprite )时,箭头将被缩放并改变其大小。我怎样才能避免它?我希望箭头保持其大小。 这是我在向场景添加新
我是一名优秀的程序员,十分优秀!