Re: Confused about floats
Re: Confused about floats
- Subject: Re: Confused about floats
- From: Gregory Weston <email@hidden>
- Date: Tue, 05 Oct 2010 09:27:31 -0400
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 (email@hidden)
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:
This email sent to email@hidden