Updating texture not working

时光毁灭记忆、已成空白 提交于 2019-12-25 07:28:09

问题


Not working update on this texture. The code is an abbreviated version and I need it so. I need to update the texture. How would I be able to do this in Swift in SpriteKit?

func didBeginContact(contact: SKPhysicsContact) {        
    if firstBody.categoryBitMask == PhysicsCatagory.ball && secondBody.categoryBitMask == PhysicsCatagory.coin
    {
        vyhodnoceni()
        screen(2)

    }}

override func update(currentTime: NSTimeInterval) {
    vysledekHvezdyTexture = SKTexture(imageNamed: starString1!)}

func vyhodnoceni(){
starString1 = "hvezdy1"}

func screen(number: Int){
    if number == 2 {
        vysledekHvezdy = SKSpriteNode(texture: vysledekHvezdyTexture)
        vysledekHvezdy.size = CGSize(width: screenSize.width / 2, height: screenSize.height / 10.5)
        vysledekHvezdy.position = CGPoint(x: self.frame.width / 2, y: self.frame.height / 2.3)
        vysledekHvezdy.zPosition = 11
        vysledekHvezdy.alpha = 0.0
        vysledekHvezdy.runAction(SKAction.fadeInWithDuration(0.7))
        self.addChild(vysledekHvezdy)
    }
}

回答1:


What I do to update textures is:

let changeTexture = SKAction.animateWithTextures([page1], timePerFrame: 0.1)
bg.runAction(changeTexture)

let me know if that works.



来源:https://stackoverflow.com/questions/37903386/updating-texture-not-working

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!