Results 1 to 2 of 2
Discuss No help on iPhone SDK forums for this newb question at the Genuine Mac Support - Hackint0sh.org; Sooo, I'll give this place a shot... My wife has commented on my loss of ...
  1. #1
    Newbie Array

    Join Date
    Dec 2009
    Posts
    2
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default No help on iPhone SDK forums for this newb question

    Sooo, I'll give this place a shot...

    My wife has commented on my loss of hair the past 2 days on this. I took the project "Which Way Is Up" from iPhone Cookbook and thought about making a learning app that was like Twister/Life/boardgame where you flick the spinner and it spins to whatever slot. I just took the app in the book and modified it.

    It's real simple in all you do is move your finger across the UIViewController and the centered UIImageView moves. I store the last 5 touch events in a struct array and get the average distance, time and get speed. I then use that calc to fire off a timer so that when they release their finger, the arrow spins relative to swipe.

    Problem is, while touchesMoved is handled, the image seems to be in a context or something, not really updating as you let off your finger, it snaps back to the beginning pos, then moves on my timer.

    LOL seems so awefully simple to just update a windows pos on the fly LOL


    here's the setup..

    Code:
    - ( void ) loadView
    {
    ...
    gView = [ [ [ UIImageView alloc ] initWithFrame : CGRectMake ( 0.0, 0.0,  rect.size.width / 3 , rect.size.width - 25 ) ] retain ] ;
    [ gView setCenter : axis  ] ;
    [ gView setImage :[ UIImage imageNamed : @"arrow.png" ] ] ;
    [ self.view addSubview : gView ] ;
    ...
    }

    By getting the origin.x and origin.y after the affinetransform, I found the pos updates and I can copy those values to later apply to the UIImage to update it. drawRect is not something Ive done in iPhone and seemed alot of extra work just to update a windows pos, so I figured this would be quick and easy.

    things ive tried...

    Code:
    		deltaX = gView.frame.size.width ;
    		deltaY = gView.frame.size.height ;
    		CGFloat z = gView.layer.zPosition ;
    
    
    gView.transform = CGAffineTransformMakeRotation ( degreesToRadian(angleDelta) ) ;
    
    		CGRect gFrame = gView.frame ;
    		gFrame.size.width = deltaX ;
    		gFrame.size.height = deltaY ;
    
    /**********
    Cant find the proper way to set z Pos on a cgrect frame
    ***********/
    
    		gView.layer.frame = gFrame ;
    this makes the png move arond the z axis also and zoom in/out etc.

    so, I tried this...

    Code:
    [gView.layer setValue : [NSNumber numberWithFloat:gFrame.origin.x] forKeyPath : @"transform.rotation.x"];
    [gView.layer setValue : [NSNumber numberWithFloat:gFrame.origin.y] forKeyPath : @"transform.rotation.y"];
    [gView.layer setValue : [NSNumber numberWithFloat:z] forKeyPath : @"transform.rotation.z"];
    turns ok, but its in 3d, i want it to turn flat.

    I cant set the bounds or pos on the frame, not enough xp I guess. But this is something that seems so very simple and the app is multi threaded with many timers, something so very simple stumbling me up is frustrating. Anyone wanna give a brother a hand in figuring this out?

    Thanks



  2. #2
    Newbie Array

    Join Date
    Dec 2009
    Posts
    2
    Post Thanks / Like
    Downloads
    0
    Uploads
    0
    Rep Power
    0

    Default

    Figured this out on my own, but thanks to all who read. I was transforming the image by x degrees and decided to store that in a global andat touchedEnded, transform the image that global degree.

    Gives the illusion the image was spinning under your touch as it goes to the last transformed pos.

 

 

Similar Threads

  1. newb question - will it be possible?
    By danjuan in forum Tutorials
    Replies: 0
    Last Post: 08-31-2011, 01:38 PM
  2. Newb Question
    By nickhowell25 in forum iOS 4.x (iPhone OS 4.x)
    Replies: 2
    Last Post: 08-22-2011, 08:44 AM
  3. Newb Question
    By monstertodd in forum iPhone 4
    Replies: 4
    Last Post: 07-05-2010, 07:41 PM

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Powered by vBulletin®
Copyright © 2014 vBulletin Solutions, Inc. All rights reserved.
Search Engine Friendly URLs by vBSEO
(c) 2006-2012 Hackint0sh.org
All times are GMT +2. The time now is 02:56 PM.
twitter, follow us!