So I’ve been coding this straightforward clicker recreation which has advertisements and a card match minigame. On the iPhone simulator the advertisements and card match work as they need to nonetheless as soon as on a cellular gadget they begin to break. Each single time the auto earnings replace it adjustments the advert and when within the card match minigame, reshuffles the playing cards. The identical factor occurs when the display screen is tapped for handbook earnings. I’ve narrowed the issue all the way down to the perform that auto advertisements to the earnings and the textual content that shows the present value. Does anybody understand how I can maintain updating this worth with out inflicting the advertisements to reload and the cardboard to shuffle. And likewise clarify why this downside solely happens on bodily units and never the simulator.
Secondly Earnings Perform:
func secondlyValue() {
clicks += perSecondEarnings * Float(upgrades["MasterUpgrade"]!) / 10
totalEver += perSecondEarnings * Float(upgrades["MasterUpgrade"]!) / 10
DispatchQueue.fundamental.asyncAfter(deadline: .now() + 1.0) {
secondlyValue()
}
}
Earnings Textual content:
Textual content("(format(floatNumber: Float(clicks))) Clicks").foregroundColor(Coloration("Licorice"))
Card Shuffle:
init(problem: Binding<String>,
showGame: Binding<Bool>,
anyGameOpen: Binding<Bool>,
clicks: Binding<Float>,
totalEver: Binding<Float>) {
self._difficulty = problem
self._showGame = showGame
self._anyGameOpen = anyGameOpen
self._clicks = clicks
self._totalEver = totalEver
self.photos = [
("DiamondKitty", .cyan, .black),
("DiamondKitty", .cyan, .black),
("Kitty", .lightGray, .black),
("Kitty", .lightGray, .black),
("GoldenKitty", .yellow, .black),
("GoldenKitty", .yellow, .black),
("WizardKitty", .blue, .black),
("WizardKitty", .blue, .black),
("BlingKitty", .green, .black),
("BlingKitty", .green, .black),
("PartyKitty", .orange, .black),
("PartyKitty", .orange, .black),
("MexicanKitty", .brown, .black),
("MexicanKitty", .brown, .black),
("SneakyKitty", .red, .black),
("SneakyKitty", .red, .black),
("SmartKitty", .systemMint, .black),
("SmartKitty", .systemMint, .black),
("AngstyTeenKitty", .magenta, .black),
("AngstyTeenKitty", .magenta, .black)
].shuffled()
self.shuffled = [
[images[0], photos[1], photos[2], photos[3]],
[images[4], photos[5], photos[6], photos[7]],
[images[8], photos[9], photos[10], photos[11]],
[images[12], photos[13], photos[14], photos[15]],
[images[16], photos[17], photos[18], photos[19]]
]
}
Advert Struct:
struct GADBannerViewController: UIViewControllerRepresentable {
@State non-public var banner: GADBannerView = GADBannerView(adSize: GADAdSizeBanner)
let adSize = GADAdSizeFromCGSize(CGSize(width: UIScreen.fundamental.bounds.dimension.width, top: 50))
func makeUIViewController(context: Context) -> UIViewController {
let bannerSize = adSize
let viewController = UIViewController()
banner.adSize = bannerSize
banner.adUnitID = "ca-app-pub-////////////////////"
banner.rootViewController = viewController
viewController.view.addSubview(banner)
viewController.view.body = CGRect(origin: .zero, dimension: bannerSize.dimension)
banner.load(GADRequest())
return viewController
}
func updateUIViewController(_ uiViewController: UIViewController, context: Context){
let bannerSize = adSize
banner.body = CGRect(origin: .zero, dimension: bannerSize.dimension)
banner.load(GADRequest())
}
}
The sport is on the appstore below the identify ‘Kitty Clicker’ if you wish to see what I imply by the loopy updating. Sadly, the bug is at the moment within the newest replace.