Also if x is a float, make sure you use the proper type cast, or values, ie  ( 
x = x + 120.00) or (x = y + (double)z , where x and y are double and z is an 
int). 

Remember int, float, double, are C types, and typecasting rules should be in 
effect.



> From: gwes...@mac.com
> Date: Tue, 5 Oct 2010 09:27:31 -0400
> To: cocoa-dev@lists.apple.com
> Subject: Re: Confused about floats
> 
> Amy Heavey wrote:
> 
> > I've got two float values (x and y) that I'm using to change the  
> > coordinates of a drawing action that is being looped through. I can  
> > add a value to x and it draws the next image along, but I want to test  
> > the value of x and if it is out of bounds I want to reset it to zero  
> > and increase y, so I get a grid of images drawn.
> > 
> > For some reason, even though I can do
> > x = x+128;
> > and it moves the image accross, x seems to be null so I can't test  
> > against it, my if statement ' if (x > 300){' always fails.
> > 
> > This must be something really simple I just can't see it this morning?  
> > I'd appreciate any help.
> 
> This doesn't make a whole lot of sense. There's no such thing as a null float 
> value and you shouldn't need to be saying "x seems to be" any particular 
> value given that you have a debugger and can actually examine the value.
> 
> Frankly, my guess is that your problem is the second argument to the drawing 
> method:
> 
> >     [img drawInRect:NSMakeRect(x,y,100,100)
> >               fromRect:NSMakeRect(x,y,100,100)
> >              operation:NSCompositeCopy
> >               fraction:1];
> 
> Are you sure that the interesting part of each source image is offset within 
> its whole internal coordinate space by the same amount as you intend to draw 
> it into the destination. Or should that second argument perhaps be replaced 
> by a rectangle whose origin is at (0,0)?
> 
> 
> _______________________________________________
> 
> Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)
> 
> Please do not post admin requests or moderator comments to the list.
> Contact the moderators at cocoa-dev-admins(at)lists.apple.com
> 
> Help/Unsubscribe/Update your Subscription:
> http://lists.apple.com/mailman/options/cocoa-dev/shashaness%40hotmail.com
> 
> This email sent to shashan...@hotmail.com
                                          
_______________________________________________

Cocoa-dev mailing list (Cocoa-dev@lists.apple.com)

Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com

Help/Unsubscribe/Update your Subscription:
http://lists.apple.com/mailman/options/cocoa-dev/archive%40mail-archive.com

This email sent to arch...@mail-archive.com

Reply via email to