Spritekit iAds弄乱了场景的大小 [英] Spritekit iAds messing with scene size

查看:69
本文介绍了Spritekit iAds弄乱了场景的大小的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用spritekit制作游戏,除添加代码添加iAd之外,其他所有功能均正常运行.当我添加iAd时,一切正常,但显示时iAd似乎正在调整场景的大小.

I am making a game using spritekit and everything works perfectly except when I add the code to add an iAd. When I add the iAd everything works but it seems that the iAd is resizing the scene when it is being displayed.

这是我显示iAd的代码,它位于ViewController.m中:

This is my code to display the iAd, it is in the ViewController.m :

 #import <iAd/iAd.h>
 #import "ViewController.h"
 #import "MainMenu.h"


 @implementation ViewController

 - (void)viewDidLoad
 {
     [super viewDidLoad];

     // Configure the view.
     SKView * skView = (SKView *)self.originalContentView;
     skView.showsFPS = YES;

     // Create and configure the scene.
     SKScene * scene = [MainMenu sceneWithSize:skView.bounds.size];
     scene.scaleMode = SKSceneScaleModeAspectFill;

     self.canDisplayBannerAds = YES;

     // Present the scene.
     [skView presentScene:scene];
 }

就像我说的那样,iAd会显示出来,并且所有功能都正常,但是当显示iAd时,它会使场景变小,有没有一种方法或某种方法可以使场景不被调整大小?

Like I say, the iAd shows up, and all the function properly but the when the iAd is displayed it makes the scene smaller, is there a method or something that allows the scenes to not be resized?

非常感谢您的帮助!

推荐答案

好,所以我想通了,我使用的是SKSceneScaleModeAspectFit的scaleMode,现在我将其更改为SKSceneScaleModeFill,这似乎会使场景更短,但事实并非如此.与AspectFit缩放模式一样引人注目.我还注意到,iAd实际上不会扭曲精灵,因为它实际上会扭曲屏幕或调整屏幕大小.如果有人知道如何在视图顶部创建iAd,例如sprite,请添加评论或解决方案.

Ok so I sort of figured it out, I was using scaleMode of SKSceneScaleModeAspectFit I have now changed it to SKSceneScaleModeFill this seems to make the scene shorter but it is not as noticeable as the aspectFit scale mode. I have also noticed that the iAd does not act like a sprite as it actually distorts or resizes the screen. If anyone knows how to create the iAd on top of the view, like sprite, please add a comment or solution.

编辑

我刚刚发现可以在界面构建器中的视图控制器中添加ADBannerView,这将在所有场景中展示广告.现在,我试图弄清楚如何将其设置为不显示在特定场景中,而看到spritekit仅使用一个viewcontroller.

I have just figured out that one can add an ADBannerView to the viewcontroller in the interface builder, this will show the ad on all scenes. I am now trying to figure out how this can be set to not display on specific scenes seeing spritekit only uses one viewcontroller.

如果通过在AdBannerView中添加来添加广告,则必须在视图控制器中创建单独的方法来打开或关闭广告,通过创建这些单独的方法,它可以使您手动控制视图中的广告任何场景的控制器.

If you add the ad by adding in the AdBannerView then you have to create seperate methods in the view controller to turn the ads on or off, by creating these seperate methods it allows one to have manual control over the ads in the view controller from any scene.

在视图控制器中,您创建了一个场景,该场景变量/对象具有tag或userdata的属性.因此,如果您的游戏转到其他场景,您可以致电

In the view controller you have a scene that you create, this scene variable/object has a property of tag or userdata. So if your game goes to a different scene you can call

[super scene] setTag:x]

每次NSTimer调用我的控制方法时,它都会在视图控制器中检查scenes标签的值,并根据该值删除或重新显示广告.

Every time that the NSTimer calls my control method it checks the value of the scenes tag in the view controller and based on that value it will remove or re-display the ad.

这篇关于Spritekit iAds弄乱了场景的大小的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆