简体   繁体   中英

xCode Sprite-Kit - Background Image in every Scene

My GameViewController redirects after start to the Menu Scene, which has white collar as background in its didMoveToView method. After a button press there, it redirects to GameScene , where:

override func didMoveToView(view: SKView) {

    self.addChild(bgImage)
    bgImage.position = CGPointMake(CGRectGetMidX(self.frame), CGRectGetMidY(self.frame))

Anyway, this image already shows up in the menu, even though it is not mentioned at all in the code for the menu scene. Furthermore, it blocks 80% of the screen, it is on top of everything, so instead of being a background, it is an image on top of everything.

In the actual GameScene it is also on top of my Game Action, while the 20% of the screen has the grey background (Game Action is still working though).

Any ideas on how to fix this?

可能想说出self.insertChild(bgImage,atIndex:0)

您可以通过修改z位置将图像移至背景,例如:

   bgImage.zPosition = -10

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM