Skip to content
This repository has been archived by the owner on Jul 6, 2021. It is now read-only.

Negative ZOrder corrupted after save/load. #65

Open
psineur opened this issue Oct 16, 2011 · 3 comments
Open

Negative ZOrder corrupted after save/load. #65

psineur opened this issue Oct 16, 2011 · 3 comments

Comments

@psineur
Copy link
Collaborator

psineur commented Oct 16, 2011

Subj. All zOrder works ok, except negative values.
Don't use -1, -2, etc values for Z for any sprites. After loading csd file again - you will get these sprites on top with biggest value instead.

@lijinlong
Copy link

The following code may help the issue or not
change the line in the end of function - (void) setupFromDictionaryRepresentation: (NSDictionary _) aDict in CSSprite.m
[self _setZOrder: [[aDict objectForKey:@"posZ"] floatValue]];
to
void (_setter)(id, SEL, NSInteger);
setter= (void (*)(id, SEL, NSInteger)) [self methodForSelector: @selector(_setZOrder:)];
setter(self, @selector(_setZOrder:), [[aDict objectForKey :@"posZ"] intValue]);

@psineur
Copy link
Collaborator Author

psineur commented Nov 3, 2011

Emm, i don't think so.

Probably there's signed to unsigned cast somewhere, probably in model.

@lijinlong
Copy link

As mentioned at http://stackoverflow.com/questions/155964/what-are-best-practices-that-you-use-when-writing-objective-c-and-cocoa
In general, methods in different classes that have the same selector (the same name) must also share the same return and argument types. This constraint is imposed by the compiler to allow dynamic binding.

IN CSSprite.m file we defined:
@interface CCNode (Internal)
-(void) _setZOrder:(int) z;
@EnD
BUT in CCNode.m it is
-(void) _setZOrder:(NSInteger) z;

and I change to -(void) _setZOrder:(NSInteger) z; in CSSprite file it could work.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants