因此,目前,我有一个使用精灵套件制作的游戏,并使用这种方式将所有内容调整到屏幕尺寸:
buyButton = SKSpriteNode(texture: SKTexture(imageNamed: "BuyButton"), color: .clear, size: CGSize(width: frame.maxX / 2.9, height: frame.maxY / 10))
buyButton.position = CGPoint(x:-frame.maxX + frame.midX*2, y: -frame.maxY + frame.midY*1.655)
addChild(buyButton)
Run Code Online (Sandbox Code Playgroud)
如您所见,它使用框架来计算宽度和高度以及节点在场景中的位置,这适用于从6s到8 Plus的所有屏幕尺寸。但是当谈到iPhone X时,就出现了问题。它似乎可以拉伸所有东西,因为与iPhone 8 Plus相比,屏幕尺寸更大且形状奇特,如下图所示
我一直在寻找这个问题的解决方案,但没有一个真正的帮助,或只是甚至更糟糕的是,我无法理解如何通过编程在该解决方案使用安全区域布局在我的精灵套件的项目像这里
我的问题是
我该如何使所有内容都适合iPhone X的屏幕,以使其适合并且不会切断得分标签和我右上角的内容?
编辑2:
itemDescriptionLabel = UILabel(frame: CGRect(x: frame.maxX - 150, y: frame.maxY - 130 , width: frame.maxX / 0.7, height: frame.maxY / 3.5))
itemDescriptionLabel.font = UIFont(name: "SFCompactRounded-Light", size: 17)
itemDescriptionLabel.text = "This purchase stops all the popup ads that happen after a certain amount of …Run Code Online (Sandbox Code Playgroud) I've implemented in app purchases into my shop scene for my game and have been having problems when changing from the shop scene to another scene it seems to crash the game and gives me this error
Thread 1: EXC_BAD_ACCESS (code=1, address=0x840f8010)
Run Code Online (Sandbox Code Playgroud)
Or it gives me a multiple version of other errors such as:
Thread 1: EXC_BAD_ACCESS (code=1, address=0x3f8)
Run Code Online (Sandbox Code Playgroud)
it also sometimes gives me an error that changes lines in the subclass like so
When I comment out the code …
当用户单击促销应用程序商店产品时,此代码就是在Apple开发人员网站上给出的代码,它告诉您检查是否可以完成交易?我该如何检查?因为那样的话我必须照顾交易是否失败或推迟,并且似乎无法弄清楚该怎么做。
//MARK: - SKPaymentTransactionObserver
func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment,
forProduct product: SKProduct) -> Bool {
// Check to see if you can complete the transaction.
// Return true if you can.
return true
}
Run Code Online (Sandbox Code Playgroud)
我还需要满足以下一些场景,这些场景与检查交易是否可以完成是相同的
func paymentQueue(_ queue: SKPaymentQueue, shouldAddStorePayment payment: SKPayment,
forProduct product: SKProduct) -> Bool {
// ... Add code here to check if your app must defer the transaction.
let shouldDeferPayment = ...
// If you must defer until onboarding is completed, then save the …Run Code Online (Sandbox Code Playgroud) 因此,我已经在游戏中实现了手势识别器来检测玩家的移动,但发现它们没有给我想要的结果,所以我正在考虑在触摸方法中制作滑动手势,并在触摸方法中制作轻击手势。触法。我已经设法使点击功能在触摸方法中工作,但我无法在触摸方法中实现滑动功能,而且我似乎找不到有关如何执行此操作的教程。下面的代码显示了我用来尝试实现此目的的触摸方法:
class GameScene: SKScene {
var touchOrigin = CGPoint()
var player = SKSpriteNode()
override func didMove(to view: SKView) {
backgroundColor = .black
player = SKSpriteNode(texture: nil, color: .orange, size: CGSize(width: 50, height: 50))
player.position = CGPoint(x: 0, y: 0)
addChild(player)
}
override func touchesBegan(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func touchesMoved(_ touches: Set<UITouch>, with event: UIEvent?) {
}
override func touchesEnded(_ touches: Set<UITouch>, with event: UIEvent?) {
for touch in touches {
var currentTouchPosition = touch.location(in: self) …Run Code Online (Sandbox Code Playgroud)