jjzjj

gameViewController

全部标签

ios - SpriteKit : Passing variable from GameViewController to GameScene

我在Storyboard中创建了一个菜单,它通过segue将一些信息传递给GameViewController。理想情况下,我可以使用该segue将信息直接传递到我需要的GameScene.swift,但我不确定这是一个选项,因为场景只是一个View而不是ViewController。因此,我将信息传递给GameViewController,效果很好。但是现在,我如何将它发送到GameScene.swift?从菜单转到GameViewControllerfuncpassToGame(game:String){performSegue(withIdentifier:"toGameSegu

xcode - 模拟器中的黑屏问题

我正在为iPad开发一款游戏,我让它以菜单屏幕启动。有一段时间,菜单屏幕会在模拟器中正常显示。我正在使用xcode在启动基于View的应用程序时提供的主视图Controller。但是,不幸的是,我不小心切断了UIView和界面生成器中的ViewController之间的连接,重新连接后,屏幕现在变成空白。当我在界面生成器中模拟屏幕时它工作正常,但在xcode中运行时却不行。这是ViewController的代码:////FunctionMachineViewController.h//FunctionMachine////CreatedbyKameronSchadton5/24/11.

ios - 无法将类型 'UIView' 的值转换为 'SCNView'

应用程序构建良好,直到我开始向Storyboard添加按钮然后我收到上述错误。它在我的GameViewController中的这一行代码处停止。letscnView=self.viewas!SCNViewStoryboard本身将其自定义类设置为GameViewController(没有SCNView选项)。GameViewController本身继承自UIViewController。我正在使用Xcode7.2。 最佳答案 确保在文件顶部也导入SceneKit。importSceneKit打开“Main.storyboard”文件

ios - 在 GameScene.swift 中显示 UIActivityViewController

我开发了一个小游戏,它由主菜单、游戏本身和一个游戏结束标签组成。我的问题是我已经在GameScene.swift文件中以编程方式添加了所有内容。现在我可以使用这行代码呈现一个UIActivityViewController:classGameScene:SKScene,SKPhysicsContactDelegate{vargameViewController:GameViewController!在GameViewController.swift中,我将这段代码放在viewDidLoad()函数中:scene.gameViewController=self然后我将以下函数添加到我的G

ios - 开始游戏时停止背景音乐

我使用以下代码在GameViewController.swift中启动应用程序时播放背景音乐:classGameViewController:UIViewController{//VARIABLESvarbackgroundMusicPlayer:AVAudioPlayer!//AUDIOPLAYERfuncplayBackgroundMusic(filename:String){leturl=NSBundle.mainBundle().URLForResource(filename,withExtension:nil)varerror:NSError?=nildo{backgroun

ios - 在其他场景中显示插页式广告 - Admob、SpriteKit、Swift

我如何每x次用户死亡或每x次用户执行按钮等操作时显示来自admob的插页式广告?这就是我在GameScene上展示插页式广告并使用简单的if语句限制广告印象的方式。 最佳答案 仅当您拥有GoogleMobileAds.sdk并将googlemobileads模块导入到您的GameViewController和GameScene或GameOverScene中时,这才有效。我将向您展示跨场景广告实现和以编程方式限制广告展示。首先,在您的GameViewController中:importGoogleMobileAdsclassGameV

ios - 在不初始化新对象的情况下转到 UIViewController

我正在使用Swift2.0在iOS9中构建。我的起始UIViewController是我的菜单屏幕。它包含以下代码:overridefuncprepareForSegue(segue:UIStoryboardSegue,sender:AnyObject?){ifletid=segue.identifierwhereid=="GamePlayScene"{self.gameVC=segue.destinationViewControlleras?GameViewControllerself.gameVC!.delegate=selfiflets=senderas?GKTurnBasedM

ios - 如何从 GameScene 刷新 GameViewController?

我成功测试了应用内购买后广告的移除。我只需要在他们完成付款并完成交易后,当前GameScene上的横幅广告仍然存在。为了删除它们,我必须重新启动该应用程序。我的GameViewController在vi​​ewDidLoad函数中进行了检查。在GameScene中完成交易后,如何“刷新”viewDidLoad?overridefuncviewDidLoad(){super.viewDidLoad()NSNotificationCenter.addObserver(self,selector:"doRemoveAds:",name:"RemoveAds",object:nil)iflet

xcode - 如何在我的 GameViewController.swift 中加载不同于 GameScene.swift 的 spritekit 文件?

在GameViewController.swift中,我找到了这一行ifletscene=GameScene(fileNamed:"GameScene"){而且我一直认为,如果我想加载GameScene.swift以外的东西,我只需将“GameScene”更改为“LandingPage”,一切都会正常进行。然而,正如我最近发现的那样,这里的“GameScene”实际上是指GameScene.sks而不是swift文件。我希望制作一款具有多个级别的游戏,每个级别都写在自己的swift文件中。我应该去哪里/如何从level1.swift移动到level2.swift?

ios - 关闭 SKScene 回到 UIKit 菜单

一旦我的SpriteKit游戏结束,我想回到我的UIKitMenuViewController。根据我目前了解到的情况,使用protocol/delegate是最好的(?)选项,但我无法让它发挥作用。我知道该协议(protocol)可能会高于GameViewController的类声明,看起来像这样:protocolGameViewControllerDelegate{vargameOver:Bool?}但我需要帮助从GameScene访问它并让它关闭GameViewController。以下是应用程序的骨架,以防有帮助。菜单ViewControllerclassMenuViewCon
12