spritebuilder / SpriteBuilder

Objective-C Game Development Suite
http://www.spritebuilder.com/
Other
741 stars 293 forks source link

moving image causes sprites to lose the image reference, displays "Missing Resource" instead #464

Open LearnCocos2D opened 10 years ago

LearnCocos2D commented 10 years ago

Very easy to reproduce:

Notes:

log:

Assertion failure in -[CCTextureCache addImage:], /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/cocos2d-iphone/cocos2d/CCTextureCache.m:273

Refers to: NSAssert(path != nil, @"TextureCache: fileimage MUST not be nil");

call stack:

Thread 1, Queue : com.apple.main-thread
#0  0x00007fff913a8e4a in objc_exception_throw ()
#1  0x00007fff90ab3038 in +[NSException raise:format:arguments:] ()
#2  0x00007fff85929d41 in -[NSAssertionHandler handleFailureInMethod:object:file:lineNumber:description:] ()
#3  0x00000001002ba4d1 in -[CCTextureCache addImage:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/cocos2d-iphone/cocos2d/CCTextureCache.m:273
#4  0x00000001000a397c in +[TexturePropertySetter setSpriteFrameForNode:andProperty:withFile:andSheetFile:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/TexturePropertySetter.m:75
#5  0x00000001000a6b66 in +[CCBReaderInternal setProp:ofType:toValue:forNode:parentSize:withParentGraph:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:296
#6  0x00000001000a8943 in +[CCBReaderInternal nodeGraphFromDictionary:parentSize:withParentGraph:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:485
#7  0x00000001000a8185 in +[CCBReaderInternal nodeGraphFromDictionary:parentSize:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:414
#8  0x00000001000a8e6d in +[CCBReaderInternal nodeGraphFromDictionary:parentSize:withParentGraph:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:522
#9  0x00000001000a8185 in +[CCBReaderInternal nodeGraphFromDictionary:parentSize:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:414
#10 0x00000001000a9732 in +[CCBReaderInternal nodeGraphFromDocumentDictionary:parentSize:withParentGraph:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:600
#11 0x00000001000a9415 in +[CCBReaderInternal nodeGraphFromDocumentDictionary:parentSize:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/CCBReaderInternal.m:565
#12 0x000000010002bd08 in -[AppDelegate replaceDocumentData:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/AppDelegate.m:1664
#13 0x000000010002ca59 in -[AppDelegate switchToDocument:forceReload:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/AppDelegate.m:1739
#14 0x000000010002d114 in -[AppDelegate switchToDocument:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/AppDelegate.m:1785
#15 0x0000000100022f56 in -[AppDelegate tabView:didSelectTabViewItem:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/AppDelegate.m:722
#16 0x0000000100081553 in -[PSMTabBarControl tabView:didSelectTabViewItem:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/libs/TabBar/PSMTabBarControl.m:1650
#17 0x00007fff8a772f20 in -[NSTabView selectTabViewItem:] ()
#18 0x000000010002f021 in -[AppDelegate openFile:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/AppDelegate.m:2033
#19 0x00000001000e078d in -[ResourceManagerOutlineHandler doubleClicked:] at /depot-koboldkit/SpriteBuilder/SpriteBuilder/ccBuilder/ResourceManagerOutlineHandler.m:535
#20 0x00007fff8a67e340 in -[NSApplication sendAction:to:from:] ()
#21 0x00007fff8a67e1be in -[NSControl sendAction:to:] ()
#22 0x00007fff8a67e0f7 in -[NSTableView _sendAction:to:row:column:] ()
#23 0x00007fff8a67b7e2 in -[NSTableView mouseDown:] ()
#24 0x00007fff8a77f0f1 in -[NSOutlineView mouseDown:] ()
#25 0x00007fff8a664b48 in -[NSWindow sendEvent:] ()
#26 0x00007fff8a6036e4 in -[NSApplication sendEvent:] ()
#27 0x00007fff8a453b89 in -[NSApplication run] ()
#28 0x00007fff8a43e913 in NSApplicationMain ()
LearnCocos2D commented 10 years ago

Note: it does not crash in release builds, instead references to the image are replaced by "Missing Texture" spriteframes.

Nevertheless this is hazardous. Consider a simple, late-project "folder restructuring" only to find out you are forced to undo all changes (if you can remember them) or re-assign each sprite's image ... ouch!

LearnCocos2D commented 10 years ago

Also consider developers not caring for or knowing about spritesheets initially, and later in the project creating a spritesheet and adding existing images to it. This poses the same problem, having to re-assign each image after creating the smart spritesheet folder.

andykorth commented 9 years ago

+1 for this issue. In particular, I wanted to combine two small spritesheets into a single sheet. Moving the files broke references in a way that wasn't very easy to figure out. Once in cocos2d, it reported missing textures, but it didn't say what CCB file contained the missing texture, so fixing it by hand was difficult.

I guess the only fix for this is associating GUIDs with each asset, and making sure files that are moved or renamed keep the same GUID. That's a somewhat big change with its own set of drawbacks.