Problems with .ccb file for sprite in SpriteBuilder - ios

I am trying to understand SpriteBuilder. I made a new file hero.ccb for sprite and set it's sprite frame to the image I need. When I go back to the MainScene and drag hero.ccb from the left menu,there is just a CCBFile without anything(no sprite image). What am I doing wrong?

This can happen if you didn't save the hero.ccb. Choose File -> Save All or simply Publish the project to have SpriteBuilder update all references.

Related

Xcode's SceneKit editor renders .dae file's wrong and Xcode sometimes crashes during preview

I'm trying to figure out how to import .dae files with animations into Xcode and SceneKit.
It works somewhat, but it's really buggy, I can't preview files, and Xcode sometimes crashes when trying to preview the .dae files in Xcode.
Here's how I'm importing the animated models
I download an animated character from Mixamo, as a Collada file, with the settings below.
Create a brand new SceneKit iOS project, import .dae file, and select the file in the Xcode file list to preview it. The result can be seen below. I have zoomed all the way out to make sure I'm not just viewing the model from the inside of the mesh. The lines extend infinetly it looks like.
If I use the ConvertToXcodeCollada workflow, and verify that the .dae XML only has one <animation> tag with corresponding closing tag, and then import it into Xcode, it won't open at all. See image below.
If I import the .dae file version not converted using ConvertToXcodeCollada, and the add .dae file as a sub reference in a .scn Scene file, the model displays correctly, and the animation is playing correctly. Image below.
So how should I do this properly?
I have also tried to import animated models into Blender and then export it to Collada from there (with unstructions from tutorials on youtube), and same results. Is there a way I can do this a proper way, where it works like it should, without Xcode behaving buggy? It would be easier if I could actually preview and edit materials etc of the .dae files directly, without having to always add them to an existing .scn Scene Kit Scene.
I did followed your instructions and try to load a 3D animation. Its working fine for me
In new sceneKit project I have updated my code like.
// create a new scene
let scene = SCNScene(named: "Jumping.dae")! //"art.scnassets/ship.scn")!
and this too
let ship = scene.rootNode.childNode(withName: "mixamorig_Hips", recursively: true)! // "ship"
I am using XCode 10.1 on macOS 10.13.6
This happen when I try to open in finder a .dae file with animation created with mixamo
https://www.mixamo.com/#/
mojave OS 10.14.1
BUG Fixed by apple 10.14.2
I have downloaded which you mentioned above link. github.com/eh3rrera/ARKitAnimation
And I opened in finder. Its working for my mac

SpriteKit .sks Files Crash Xcode 10 When Assigning Texture

Am I missing something obvious?
For reasons unknown, Xcode 10 keeps crashing on me when I go to assign a texture to a named sprite using the Scene Editor. After having to delete and recreate my .sks files a couple times, I decided to try and reproduce the issue using Xcode's game template. The steps I took to do this are as follows:
Open Xcode and select Create a new Xcode project.
Choose the Game template, name the project Test and save it somewhere, i.e. your desktop.
Drag any image asset into Assets.xcassets. I used this green square:
Open GameScene.sks and drag a Color Sprite onto the scene.
Name the sprite something descriptive like square_green.
Attempt to set the texture in this field:
Other similar questions on Stack Overflow:
Xcode is crashing in SpriteKit
XCode 9 Crashing while setting a Texture in SKScene in Spritekit
If I do not set a name for the color sprite prior to assigning a texture, everything works fine. However, if Xcode is forced to crash at least one time, I have to delete the .sks file completely just to get Xcode to open again.
For the time being I've decided to avoid the trouble all together and just assign the textures programmatically in the didMove(to:) of my SKScene class:
override func didMove(to view: SKView) {
let greenSquare = childNode(withName: "square_green") as! SKSpriteNode
greenSquare.texture = SKTexture(imageNamed: "square_green")
}
I ran into the same problem, and later I moved the images out of Assets.xcassets and the problem was solved. I guess the image can't be placed in Assets.xcassets.

Object disappear from Scene

I use SceneKit to construct a 3D Scene, which contains a few object. I convert all the COLLADA file and OBJ file to SCN file. Then I use a blank SCN file to put all the object together.
It looks fine in SceneEditor. And it runs on iPad. Everything looks exactly like it was in the SceneEditor.
Then I come up with some idea with the scale of one object. I change it in the property bar. It looks nice at the SceneEditor. And I tried to run it again.
Then boooom.
There was only one object left in the scene. Everything was gone. I can see all the object on SceneEditor. They just not show up on my iPad.
This happens all the time -- after I change any property of any object on the scene, the scene went wrong.
So far I was trying to build a new SCN file again with all those objects. But as the project gets bigger this might be a nightmare.
What is going on? Do you guys have any solution?
UPDATE:
I've notice that the Full Path of the normal SCN files I add in the scene look like: "/xxx.scn". But after some editing, it automatically changed to "xxx.scn" without slash. I think this may be the reason why objects disappear. The wrong path leads to nil and BANG.
Everytime when I use "Quick View" it will automatically change the Full Path. Even if I don't do anything.
I tried to relocate the file but the Full Path stay with no slash. PLS someone help me with it.

swift file not linked to sks file and not changing

So I have a game so far and everything seems to be working very well. I'm only using the basic gamescreen.swift that is default project along with the .sks file for it as well. After a certain condition is met (opponent winning by certain amount of points), it transitions to the .sks file. I even double checked by removing the .sks file to see if it was maybe just transitioning to the .swift file but when I did that I got the nil error (for obvious reasons).
So when I do things like (below) on the .swift file it should theoretically change the .sks file and how it looks visually when I build, but it doesn't. Nothing happens
var background = SKSpriteNode(imageNamed: "theimage")
override func didMove(to view: SKView) {
background.position = CGPoint(x: frame.size.width / 2, y: frame.size.height / 2)
addChild(background)
}
So then I remove everything from the .swift file and instead manually add the image to the .sks file and it doesn't do a single thing when I build it.
So I'm thinking, maybe it's just not even showing the .sks file, but rather a random thing. So I changed the background of the .sks file and built it and the change occurred. I made sure I checked with multiple colors and it didn't work. I just was wondering why if I manually add image to the .sks it's not working yet when I change background image it does...hm
Next time if anyone encounters this make sure that the image you're trying to add as a node isn't significantly large. That was my issue but when I resized the image it all worked out :D

XCode Has No Option to Enable Texture Atlas Generation

I'm following along with this apple doc, but for some reason when I search for "Sprite" under Build Settings in XCode nothing pops up. I've also tried searching for "Enable Texture Atlas Generation" and nothing comes up.
I have Xcode 5.0.2 if that helps.
The SPRITEKIT_TEXTURE_ATLAS_OUTPUT settings will be there in a new project but the SpriteKit Deployment Options will be created later. Of course you must select SpriteKit Game template when you create the project.
These settings added automatically to your project when you add the first texture atlas resource to it. You need to add a folder named with the .atlas extension. For example you have textures for your hero the atlas should be named as hero.atlas.
I was bedeviled by this exact issue for the past day, when I discovered that if I add an atlas to the project by dragging and dropping, the Sprite Kit Texture Atlas Options were not added to the Build Settings. If I chose File > Add Files to... from the menu bar, however, the Sprite Kit Texture Atlas Options appeared in the Build Settings.
So, apparently, do not drag and drop to add a texture atlas.

Resources