Hello. I am sorry to bother so late, but i am very much a bundle of nerves. I have tried to understand how to use the information in the couple of objective-c and objective-c game design books I have purchased, but unfortunately, the information is laid out in a way which I dont really comprehend.
I would like to state my query and issue in a way which models on what I am trying to do, since most of the basic explanations I have tried to understand in the manuals have helped in a way but have left me baffled with many issues.
I am trying to create a game in which 3 types of enemies appear and make their way from 1 side of the scree to the other. The enemies are animated as they move and you have to touch them to cause them damage. 1 enemy dies after 1 hit, whilst the other 2 require 2 or 3 touches to kill. When you kill the enemy, there is a death animation, done for each enemy type.
Using a framework called Sparrow, I have tried to work on this issue and I have for most part succeeded. Sadly, I have failed to do a number of things. I can only use 1 enemy death animation, the enemies all die after 1 touch and all the code is on 1 file (stage.h and stage.m).
I write this not in request for you to aid me in figuring out how to deal with all these issues, I am trying to sort them out in other ways; but on how to have a method interact with another method or have a file drawing data from another file.
The following code is part of the enemy creation coding I am using from the method addEnemy. SPMovieClip is a special function of Sparrow, which stores images in it and then waits for a command which allows it to play the images i a certain order. The first image of each enemy is drawn from an NSMutableArray which is stored in the stage.m file in the init method.
NSString *eMoveTexture=[enemyTextures objectAtIndex:rand];
enemyAnimation = [[SPMovieClip alloc] initWithFrame:[atlas1 textureByName:eMoveTexture] fps:6];
for(int i=0; i<=5; ++i)
{
NSString *frame = [NSString stringWithFormat:@"eMove%d_%d", rand+1, i];
[enemyAnimation addFrame:[atlas1 textureByName:frame]];
}//FOR END
I would like to ask, using this code as an example, how I could extract this code, make a new method (e.g. -(void)addEnemyType1), insert this code into the method and have the original addEnemy method read this code to draw the contents so that the enemyAnimation properties could be inserted into another SPMovieClip.
By now some must be horrified by my ignorance, but I have been trying very hard to make these issues work, but my brain has been failing to make the connections. As far as I am concerned, if I cannot understand how to get 1 method to read information from another, how could I understand how to create a new file/object from which to draw information (As i understand that to properly create enemies you have to have the animation, movement, HP and death coding all in the enemy object, which you drraw from.).
I am sorry to cause this issue, but I am very much lost on how to complete this game (deadline in 2 days time) and would like to understand how to do as i want to. Thank you for reading this far. My appologies for wasting your time, but thank you nevertheless.