问题
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