不对此纹理进行更新。代码是缩写版本,我需要它。我需要更新纹理。我怎么能在SpriteKit中的Swift中做到这一点?
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)
}
}
答案 0 :(得分:1)
我更新纹理的方法是:
let changeTexture = SKAction.animateWithTextures([page1], timePerFrame: 0.1)
bg.runAction(changeTexture)
如果有效,请告诉我。