Advertise Mobile SDKs Books Events Forum News Social Networking Support Us
Follow @iphonedevsdk on Twitter

Interface 2, Advanced iOS
Mockup & Code Gen
($9.99)

Make your own iPhone apps
and run them live!
(free)

Pic Frame Dynamo: Photo Editing
($0.99)

Abiliator
($1.99)

Want your application or service advertised on iPhone Dev SDK?

Go Back   iPhone Dev SDK Forum > iPhone SDK Development Forums > iPhone SDK Development

Reply
 
LinkBack Thread Tools Display Modes
Old 06-11-2011, 10:05 PM   #1 (permalink)
Just Some Guy
 
Join Date: Dec 2010
Posts: 112
UnretroGamer is on a distinguished road
Arrow One PNG is offset, the other doesn't even show!

I am trying to load the background of the map programatically based on a float called "progress" from 0.000000 - 1.000000

For some reason when I set it to zero, the moon is in the right place y-wise, but in the center x-wise instead of being at 0.75 of the screen at 0.000000 and 0.5 of the screen at 0.499999.

The sun doesn't appear at all ever, and it's not my math being SUPER off because when i set the center to (0,0) or self.view.center, I still don't see it... the dayImageView isn't covering it either because at 0.600000 I can't see it behind.

I'm guessing it's something with the default origin of the images or something. Anyone know why the moon is off, and the sun doesn't even appear?

Your time and help are greatly appreciated.

Code:
- (void)setupCvBackgroundView {
    //Display images
    UIImage *nightImage = [UIImage imageNamed:@"Night BG.png"];
    UIImageView *nightImageView = [[UIImageView alloc] initWithImage:nightImage];
    [cvBackgroundView addSubview:nightImageView];
    UIImage *dayImage = [UIImage imageNamed:@"Day BG.png"];
    UIImageView *dayImageView = [[UIImageView alloc] initWithImage:dayImage];
    [cvBackgroundView addSubview:dayImageView];
    UIImage *moonImage = [UIImage imageNamed:@"Moon.png"];
    UIImageView *moonImageView = [[UIImageView alloc] initWithImage:moonImage];
    [cvBackgroundView insertSubview:moonImageView aboveSubview:dayImageView];
    UIImage *sunImage = [UIImage imageNamed:@"Sun.png"];
    UIImageView *sunImageView = [[UIImageView alloc] initWithImage:sunImage];
    [cvBackgroundView insertSubview:sunImageView aboveSubview:moonImageView];

    
    //SUN/MOON POSITIONS
    float progress = [[NSUserDefaults standardUserDefaults] floatForKey:@"land1progress"];
    if (progress > 0.500000) {
        sunImageView.center = CGPointMake((self.view.frame.size.width * 0.5) + ((self.view.frame.size.width * 0.25) *((progress - 0.5) * 2)), self.view.frame.size.height - ((self.view.frame.size.height * 0.75) * ((progress - 0.5) * 2)));
        moonImageView.hidden = YES;
    } if (progress < 0.500000) {
        moonImageView.center = CGPointMake((self.view.frame.size.width * 0.75) - (self.view.frame.size.width * ((progress * 2) * 0.25)), ((self.view.frame.size.height * 0.75) * (progress * 2)) + (self.view.frame.size.height * 0.25));
        sunImageView.hidden = YES;
    } else {
        sunImageView.hidden = YES;
        moonImageView.hidden = YES;
    }
    
    //BG TRANSPARENCIES
    //display day bg over night bg
    dayImageView.alpha = progress;
    
    [nightImageView release];
    [dayImageView release];
    [moonImageView release];
    [sunImageView release];
}
UnretroGamer is offline   Reply With Quote
Reply

Bookmarks

Tags
.png, offset, png, uiimage, uiimageview

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



» Advertisements
» Online Users: 317
6 members and 311 guests
chemistry, Dnnake, iOS.Lover, lendo, Leslie80, pbart
Most users ever online was 1,387, 04-10-2012 at 04:21 AM.
» Stats
Members: 175,664
Threads: 94,120
Posts: 402,898
Top Poster: BrianSlick (7,990)
Welcome to our newest member, Leslie80
Powered by vBadvanced CMPS v3.1.0

All times are GMT -5. The time now is 02:22 AM.
Powered by vBulletin® Version 3.8.0
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0