1
\$\begingroup\$

So I am currently making a 1942-style game in Sprite Kit. I've reached the point where I am finished implementing pretty much everything (movement, shooting (also recognizing a hit and exploding an object), menu,etc..) ..expect for enemies. Since I am not so experienced in programming I wasn't quite sure how I should implement my enemies.

I wanted to have different enemy "classes" in my game (in a way where they have different appearance / weapons, etc) and I also wanted the game to spawn stronger classes in the game with time. (e.g: at the beginning of the game there are green enemies with one-shot weapons; 3minutes in they should be red and fire two-shots)

How should I code my enemies? Should I do different classes (what I am currently thinking) or should I declare them with strings or do the properties with a .plist file? (on a side node: how can I access my plist properties from the scene code?)

Do you have other tips for me regarding enemies/classes/plist files?

Or..are there any other ways specifically in Sprite Kit to do this kind of stuff?

\$\endgroup\$

1 Answer 1

2
\$\begingroup\$

If the only difference between the enemies are sprite changes and simple quantities (number of shots fired, rate of fire, etc), multiple classes would not be needed. This is exactly the sort of game Sprite-Kit was designed to make easily and quickly. Classes would be more appropriate if there was some unique behavior between the different kinds of enemy types.

A common example is that of the player compared to enemies. There are fundamental differences in how those two logical structures behave within the context of most games. Thus, different classes would be more appropriate. Different enemies with different sprites, on the other hand, assuming no fundamental differences between types, would more likely warrant a single "Enemy" class with properties defining the sprite to be used, the rate of fire and number of shots per attack, etc.

With a simple enough game, even an "Enemy" class isn't necessary, which may or may not be applicable to your game. Sprite-Kit has some impressive functionality that can be accessed entirely within the editors.

\$\endgroup\$
2
  • \$\begingroup\$ If I only create one enemy class, can I also define the path of each kind of enemy? \$\endgroup\$ Commented Jul 17, 2014 at 20:50
  • \$\begingroup\$ If the paths are simple and few, the process is simple. SpriteKit uses SKActions, which can implement simple paths involving acceleration, velocity, position, fading, and more. If you want more complicated AI or pathfinding that differs between types, it depends more on your architecture. For a 1942 style scrolling shooter, SKActions are likely plenty for your needs. \$\endgroup\$
    – Attackfarm
    Commented Jul 17, 2014 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .