Skip to content

Commit

Permalink
Fix assumed resolution of loaded assets from absolute paths.
Browse files Browse the repository at this point in the history
  • Loading branch information
slembcke committed Mar 23, 2015
1 parent 9d34010 commit b98d5ab
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion SpriteBuilder/ccBuilder/TexturePropertySetter.m
Expand Up @@ -31,6 +31,7 @@
#import "CCNode+NodeInfo.h"
#import "CCTextureCache.h"
#import "CCSpriteFrameCache_Private.h"
#import "CCFile_Private.h"

@implementation TexturePropertySetter

Expand Down Expand Up @@ -73,7 +74,18 @@ + (void) setSpriteFrameForNode:(CCNode*)node andProperty:(NSString*) prop withFi
@try
{
fileName = [CCBFileUtil toResolutionIndependentFile:fileName];
CCTexture* texture = [[CCTextureCache sharedTextureCache] addImage:fileName];

// Need to overload the regular texture cache behavior to load files from absolute paths
CCTexture* texture = [CCTexture textureForKey:fileName loader:^CCTexture *{
NSURL *url = [NSURL fileURLWithPath:fileName];

// Not 100% certain this is correct...
CGFloat contentScale = [CCSetup sharedSetup].assetScale;
CCFile *file = [[CCFile alloc] initWithName:fileName url:url contentScale:contentScale tagged:YES];

CCImage *image = [[CCImage alloc] initWithCCFile:file options:nil];
return [[CCTexture alloc] initWithImage:image options:nil];
}];

if (texture)
{
Expand Down

0 comments on commit b98d5ab

Please sign in to comment.