草庐IT

game-loop

全部标签

cocoa /swift : Loop through names of folder in path

我目前正在使用swift编写osx应用程序,但我不知道如何遍历甚至获取特定路径中所有文件夹的名称。也许是fm.enumeratorAtPath的东西? 最佳答案 我使用enumeratorAtURL。下面是一些代码,展示了如何打印用户主目录中的目录的示例。ifletdirURL=NSURL(fileURLWithPath:NSHomeDirectory()){letkeys=[NSURLIsDirectoryKey,NSURLLocalizedNameKey]letfileManager=NSFileManager.defaultM

ios - 调度组 : for-loop *and* async calls within the for-loop

我了解如何在简单的for循环中使用调度组。但是,我有一个更复杂的for循环,其中包含更多异步调用。我希望在执行组完成代码之前完成所有异步调用。我试图应用此答案中的原则无济于事-CanIusedispatchgroupnotinaloop?.这是我的代码,基于我在该链接中观察到的技术:letgroup=DispatchGroup()forrefinself.notifsRefList{group.enter()self.db.fetch(withRecordID:ref.recordID){notifRecord,notifErrinprint("asynccall")ifnotifEr

ios - Swift - 无法显示 Game Center

我正在使用此代码让GameCenter在用户按下按钮时出现。我希望在排行榜上显示他们的高分:@IBActionfuncshowScores(x:UIButton){vargameCenterController:GKGameCenterViewController!if(gameCenterController!=nil){gameCenterController.gameCenterDelegate=selfself.presentViewController(gameCenterController,animated:true,completion:nil)}}但是我在这一行得到一

c# - 统一: Apple Game Center iOS7 registers the scores for only 30 minutes in the leaderboard

我的游戏是使用Unity4.5和UnityEngine.SocialPlatforms.GameCenter制作的。我的游戏在应用商店中。如果我玩游戏并打破了我的高分,它会在GameCenter中报告,我会在排行榜上看到自己。如果我用另一台设备玩,它也会记录分数,我可以看到2个分数和2个玩家。一切看起来都很好。但是,这是我的问题,如果我在2台设备上30分钟后重新启动应用程序,分数就会从游戏中心的排行榜中消失。(如果我直接在iTunesConnect网站上查看,我的排行榜也是空的)。考虑到在沙盒模式下它运行良好,我很难解决这个问题,我的高分已经持续数周了。谢谢,如果你能帮忙。PS:我在G

ios - SwiftyJson : Looping an array inside an array

我试图在一个数组中遍历一个数组。第一个循环很简单,但我无法循环遍历其中的第二个数组。欢迎提出任何建议!{"feeds":[{"id":4,"username":"andregomes","feeds":[{"message":"Iamuser4","like_count":0,"comment_count":0}]},{"id":5,"username":"renatosanchez","feeds":[{"message":"Iamuser5","like_count":0,"comment_count":0},{"message":"Iamuser5-2","like_count"

ios - Swift 显示 Game Center 排行榜

现在我正在尝试显示我创建的排行榜。玩家身份验证正常,但打开游戏中心窗口时却很奇怪。这是一张图片:这是我用来显示这张图片的代码:overridefunctouchesBegan(touches:NSSet,withEventevent:UIEvent){self.showLeaderboard()}funcshowLeaderboard(){varleaderView=UIViewController()varleaderViewController=GKGameCenterViewController(rootViewController:leaderView)leaderViewCo

ios - Game Center - 使用 Swift 发送和接收数据

我正在尝试将以下结构从一个播放器发送到另一个播放器:structGamePacket{varaction:StringvarpointArray:[CGPoint]}我很难找出将GamePacket转换为Data并再次转换回来的正确方法。这是我目前用于发送数据包的代码:funcsend(packet:GamePacket){//convertGamePackettoDatahereletdata=Data.init()varremotePlayerArray=[GKPlayer]()ifletcurrentPlayer=self.currentPlayer,letmatch=self.

swift - 'for index'与传统 'for loop'的区别

我是Swift的新手,也是编程新手。我不确定是不是因为现在是凌晨2点34分,但有人可以帮我确定这两个循环之间的区别吗?第一个是产生我想要的值但使用(正如Swift文档所解释的那样)一个“传统的C循环”,其中后一个是使用Swift首选的“forindex”循环(我个人喜欢因为我更清楚),问题是这个循环返回每个数字而不是满足条件。funcfindLargestPrimeFactor(number:Int){forvari=2;i0{}else{print(i);}}}findLargestPrimeFactor(13195);下面是将每个数字返回到13195funcfindLargestP

swift - 无法分配给属性 : 'card' is a 'let' constant in a for loop in swift

这个问题在这里已经有了答案:"Cannotassignto"erroriteratingthrougharrayofstruct(3个答案)关闭4年前。无法分配给属性:“card”是chooseCard方法中for循环中的“let”常量。我无法弄清楚为什么错误会出现在for循环中。我在代码中遗漏了什么。请帮忙。importFoundationclassConcentration{varcards=[Card]()varfaceUpCount=0funcchooseCard(atIndex:Int){varalreadyFaceUpCard=Card()iffaceUpCount==0{

Swift SpriteKit : png image appears black while the game is being run. 我该如何解决这个问题?

我正在使用Xcode、Swift和SpriteKit制作游戏。我在photoshop中制作了一张涉及透明度的png图片,在游戏中显示为纯黑色。我还有其他png图像,它们也涉及透明度,它们以预期的方式出现。我不认为这是代码问题,但为了以防万一,这里是将图像引入游戏的代码(它在didMoveToView函数内):letwarning=SKSpriteNode(imageNamed:"yellow_warning")warning.setScale(0.1)warning.anchorPoint=CGPoint(x:0,y:0.5)warning.position=CGPoint(x:CGR