SpriteKit проблема с Atlas

spritekit

#1

Приветствую, это мое первое сообщение на просторах вашего форума ) надеюсь на помощь.

Я решил анимировать текстурку в spriteKit через Atlas, симулятор запускается без проблем, но текстурка не отображается (отображается в виде красного крестика) (ошибка Atlas ‘bee’ cannot be found.)

Код GameScene.swift

import SpriteKit
import GameplayKit

class GameScene: SKScene {

override func didMove(to view: SKView) {
    
    self.backgroundColor = UIColor(red: 0.4, green: 0.6, blue:
        0.95, alpha: 1.0)
    
    // создаем: bee sprite
    // Note: Remove all prior arguments from this line:
    let bee = SKSpriteNode()
    bee.position = CGPoint(x: 250, y: 250)
    bee.size = CGSize(width: 28, height: 24)
    self.addChild(bee)
    
    // Find our new bee texture atlas
    let beeAtlas = SKTextureAtlas(named: "bee.atlas")
    
    // Grab the two bee frames from the texture atlas in an array
    // Note: Check out the syntax explicitly declaring beeFrames
    // as an array of SKTextures. This is not strictly necessary,
    // but it makes the intent of the code more readable, so I
    // chose to include the explicit type declaration here:
    let beeFrames: [SKTexture] = [
        beeAtlas.textureNamed("bee.png"),
        beeAtlas.textureNamed("bee_fly.png")]
    
    // Create a new SKAction to animate between the frames once
    let flyAction = SKAction.animate(with: beeFrames, timePerFrame: 0.14)
    
    // Create an SKAction to run the flyAction repeatedly
    let beeAction = SKAction.repeatForever(flyAction)
    
    // Instruct our bee to run the final repeat action:
    bee.run(beeAction)
}

текстурки находятся: Enemies/bee.atlas/

Texture Atlas ‘bee’ cannot be found.


#3

У Вас атлас - папка синяя или желтая? Должен быть синей.


#4

Синяя :slight_smile:


#5

Попробуйте вот тут посмотреть:


#6

Спасибо за помощь, до вашего последнего сообщения успел разобраться, сперва добавил в системные настройки Xcode для полного доступа к файлам и папкам на компьютаре, потом создал из Xcode через Finder папку. До этого папку добавлял, я думаю архитектура папки была неверной.