gpt4 book ai didi

ios - Sprite 套件中的 UIImageView

转载 作者:塔克拉玛干 更新时间:2023-11-02 09:28:17 25 4
gpt4 key购买 nike

我正在尝试在 Sprite Kit 中按下暂停按钮时创建一个暂停菜单。这是我通过创建一个 UIImageView 来做的。问题是没有显示 UIImageView。我怎样才能做到这一点?

-(void)didMoveToView:(SKView *)view
{

UIButton *pauseButton = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
[pauseButton setImage:[UIImage imageNamed:@"pause"] forState:UIControlStateNormal];
[pauseButton addTarget:self action:@selector(pausedMenu:) forControlEvents:UIControlEventTouchUpInside];

[self.view addSubview:pauseButton];

}




-(void)pausedMenu:(SKView *)view
{

SKSpriteNode *menu = [SKSpriteNode spriteNodeWithImageNamed:@"pausemenu"];
//menu size is already image size (by default), no need to set it
menu.position = CGPointMake((self.size.width - menu.size.width) * 0.5,
(self.size.height - menu.size.height) * 0.5);
[self addChild:menu];
self.scene.paused = YES;
self.scene.view.paused = YES;


}

最佳答案

只使用 SpriteKit,为什么要使用 UIImages?

SKSpriteNode *menu = [SKSpriteNode spriteNodeWithImageNamed:@"pausemenu"];
//menu size is already image size (by default), no need to set it
menu.position = CGPointMake((self.size.width - menu.size.width) * 0.5,
(self.size.height - menu.size.height) * 0.5);
[self addChild:menu];
self.scene.paused = YES;
self.scene.view.paused = YES;

关于ios - Sprite 套件中的 UIImageView,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23346402/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com