SpriteKit backdrop PNG with alpha showing black

I have a game Spritekitcreated in Swift, and when it finishes, I have a background that has a pngfile that has an alpha value of 0.5ish (so that it looks through it). I did it in Photoshop.

I use it to quench game details and place a control card on top of it.

When I use it on my iPhone 6 and launch iOS 9.2, it works fine, fades out the details and displays a scorecard ... but when I run it on a simulator running iOS 9.2 or iPhone 5C with iOS 8.4, it just appears black .. . covering the entire screen of the game ...

It is declared as follows:

    //alpha'sd png created in photoshop. approx. 0.3 alpha
    let backdrop = SKSpriteNode(imageNamed: "Background_Alpha") 

    backdrop.anchorPoint = CGPoint(x: 0.5, y: 1.0)
    backdrop.position = CGPoint(x: size.width/2, y: size.height)
    backdrop.name = "ScoreScreen"
    backdrop.zPosition = Layer.UIBackground.rawValue
    worldNode.addChild(backdrop)

and is called like this:

    backdrop.alpha = 0
    let drop = SKAction.fadeInWithDuration(kAnimDelay)
    drop.timingMode = .EaseInEaseOut
    backdrop.runAction(SKAction.sequence([
        SKAction.waitForDuration(kAnimDelay),
        drop
        ]))

Here is a screenshot from the simulator ... but, as I mentioned, this also happens on my iPhone 5C with 8.4 ...

simulator screenshot

, - , ...

, ?

+4
1

, , :

:

Sprite Kit . , , RGBA

, , , alpha'd png, - Spritekit :

    let backdrop = SKSpriteNode(color: 
                          SKColor(red: 29.0/255.0, 
                                green: 113.0/255.0, 
                                 blue: 149.0/255.0, 
                                alpha: 0.3),         //set alpha here
                                 size: size)

    backdrop.position = CGPoint(x: size.width/2, y: size.height/2)
    backdrop.name = "ScoreScreen"
    backdrop.zPosition = Layer.UIBackground.rawValue
    worldNode.addChild(backdrop)                     //add it to world

    //because I set the alpha in the SKSpriteNode,
    //I can still animate it in from alpha=0 to alpha=0.3:

    backdrop.alpha = 0
    let drop = SKAction.fadeInWithDuration(kAnimDelay)
    drop.timingMode = .EaseInEaseOut
    backdrop.runAction(SKAction.sequence([
        SKAction.waitForDuration(kAnimDelay),
        drop
        ]))

. , png-.

, , , .

0

Source: https://habr.com/ru/post/1622260/


All Articles