Become a MacRumors Supporter for $50/year with no ads, ability to filter front page stories, and private forums.

TrentS

macrumors 6502
Original poster
Sep 24, 2011
491
238
Overland Park, Kansas
I have an NSArray animation in my game app that basically is implemented whenever a certain button is pushed, but I would rather have the animation begin when my game is first initializes. To begin the game, the player only has to tap the screen. Is there anywhere I can find out how to make my animation not dependant on said button, but rather just begin on game start up? It seems like all the video tutorials hinge on animation initialization with a connecting button. Any help would be greatly appreaciated. Thanks!

:) :) :) :)
 

JohnsonK

macrumors regular
Mar 6, 2014
142
0
NSArray animation?

You did not provide any details or code, so I can't give a better answer. You have to move your code from your button to viewWillAppear, viewDidAppear or equivalent.

Did you make the game or downloaded it from somewhere?
 
Last edited:

TrentS

macrumors 6502
Original poster
Sep 24, 2011
491
238
Overland Park, Kansas
Sweet!

NSArray animation?

You did not provide any details or code, so I can't give a better answer. You have to move your code from your button to viewWillAppear, viewDidAppear or equivallent.

Did you make the game or downloaded it from somewhere?

Yes, you are right. I am sorry. I will try and add the code when I get home tonight. It is my first attempt at making an xcode game app ( or any app for that matter ). I have learned quite a bit in about a months time, and I am amazed out how much I am loving it. When I finally write something and it works - Sweet!

I just need to figure out when to stop and call it complete. I seem to keep adding more and more features as I go. I only have a few snags that I need to iron out, then I will join the Dev. program and submit my game soon after. It is exciting!

:) :) :) :)
 

TrentS

macrumors 6502
Original poster
Sep 24, 2011
491
238
Overland Park, Kansas
Code....

Okay, here is the code.....


Under .h I have...


Code:
IBOutlet UIImageView *animateImage;

-(IBAction)startAnimating;







Under .m I have...


Code:
@implementation ViewController







  -(IBAction)startAnimating {

     animateImage.animationImages = [NSArray arrayWithObjects:[UIImage imageNamed:@"Scuba1.png"], [UIImage imageNamed:@"Scuba2.png"],

          [UIImage imageNamed:@"Scuba3.png"], nil];

   [animateImage setAnimationRepeatCount:0];

    animateImage.animationDuration = 0.95;

    [animateImage startAnimating];




  }




Right now, in order for the animation to start, the player has to tap a button ( that is just the way the tutorial had me set it up ). My game is set up to start when the player taps anywhere on the screen. I would like for my animations to start playing at that moment, instead of a button. Or they could even start when the player first opens up the app, I just wouldn't want their "movement" on the screen to start until the player taps the screen. I've tried numerous things, like moving the code under "touchesBegan" and viewDidLoad", but nothing seems to work..... Is there another tutorial I can watch, or is this so simple and I'm just missing something?

:confused: :confused: :confused: :confused:
 
Last edited by a moderator:

larswik

macrumors 68000
Sep 8, 2006
1,552
11
I might be wrong here but I would try you code in the viewWillAppear delegate method. But if memory serves me right the objects for the view are not yet initialized before viewDidLoad is called. By the time the viewWillAppear is called the objects are initialized and it should work. I ran in to this kind of problem last year and it drove me nuts. I think that was the solution.
 

JohnsonK

macrumors regular
Mar 6, 2014
142
0
It is animating for less than a second, too fast. Try viewDidAppear

PS: I suggest you to stop for a moment and begin learning the basics of programming languages before actually trying to follow a complex tutorial.
 
Register on MacRumors! This sidebar will go away, and you'll see fewer ads.