> > CGFloat is a float, yet it returns 0??? WTF?
>
> It isn’t a float. What you’re seeing in the debugger *confirms* that CGFloat
> is 64 bits.
Hmm.. I guess I don't understand that then. My logic was because
casting as a double returns the expected value, and casting as a CGFloat
does not, that it couldn't be a double...
> You’re also confusing the concepts of a cast as a value conversion and a cast
> as a re-interpretation of the type of variable (which re-interprets the
> underlying memory bits), and that’s what Greg was trying to alert you to:
>
> >> The debugger console may interpret it
> >> differently (using the cast as a hint of the correct return type,
> >> rather than a conversion of the real return type).
I see...
> There’s something else going on here. You might want to show some
> code, including the declaration of (say) your “laserXOffset” property,
> and the line where you set the scale.
The scale code I discovered was breaking due to a protocol's interface
being used on a class that defined a different type.
So, it went like this:
@protocol MenuInteractable
-(void)setScale:(CGFloat)scale;
// other stuff
@end
Meanwhile a class in the game library:
@interface CCNode : NSObject
@property(nonatomic,readwrite,assign) float scale;
// other stuff
@end
so I had a class inherit from that:
@interface MenuItem : CCNode
@end
.. and an object using that was doing:
id item = menuItem;
item.scale = 1.0f;
//
And then when I'd get into the setter it would be assigning the value 0.
Once I changed the MenuInteractable property to:
-(void)setScale:(float)scale;
Then all my sprites were back.. I didn't even realize float was
what the actual real class was using, I assumed it was CGFloat and
that's why I put it on that protocol. And like I said, on my iPhone 6
and iPad3, it was totally ok with how that was.
...
Sorry for my temper fit. Sometimes I go argghhh when things make no
sense, and I am afraid I am going to need to go out and buy an iPhone7
now because I have no idea whether there's something else that's going
to behave differently on it compared to all these other devices.
Patrick J. Collins
http://collinatorstudios.com
On Tue, 18 Oct 2016, Quincey Morris wrote:
> On Oct 18, 2016, at 00:04 , Patrick J. Collins
> wrote:
> >
> >> Is your process 64-bit or 32-bit? CGFloat is float in 32-bit processes and
> >> double in 64-bit processes.
> >
> > I'm not sure what you mean? The app is intended to work on both 32-bit
> > and 64-bit architectures. My iPad3 is a 32-bit device, and my iPhone-6
> > is a 64-bit device. On both of those devices everything is fine and
> > casting 1.0 as either a CGFloat or float with both result in 1.0 (as
> > expected). On the iPad pro, this bogus behavior happens where 1.0 cast
> > as a CGFloat becomes 0.
>
> You’re having a little temper fit here, which is fine by me except that it’s
> leading you into technical incorrectness, not to mention contradicting
> yourself. You said:
>
> > (lldb) expr (float)[self.fireable laserXOffset]
> > (float) $11 = 0
> > (lldb) expr (CGFloat)[self.fireable laserXOffset]
> > (CGFloat) $12 = 400
>
> > (lldb) expr (double)[self.fireable laserXOffset]
> > (double) $15 = 400
>
>
> That is, according to you, casting *as a float* produces 0, and casting as
> CGFloat or double [identical in iPad Pro as in iPhone 6/7] produce the same
> non-zero value. Somehow, though, you’ve mixed this up:
>
>
> So, back to your actual problem:
>
> > Yes, when I first tried my game on the iPad pro, a huge percentage of my
> > sprites were invisible, and it was because their scale was being set to
> > 1.0 as CGFloats, which was turning into 0. So I had to make sure all
> > the places where scale was being set was using an actual float type.
>
>
> > I feel like I should just sed -i my entire
> > project and turn all CGFloats into floats... But I am not sure if that's
> > really a good idea.
>
> No, that’s a really terrible idea. Voodoo solutions always are.
>
>
>
___
Do not post admin requests to the list. They will be ignored.
Objc-language mailing list (Objc-language@lists.apple.com)
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/objc-language/archive%40mail-archive.com
This email sent to arch...@mail-archive.com