From fd58a0cde1bb5473e39e6cb82d28113da84b9ae0 Mon Sep 17 00:00:00 2001 From: Starla Insigna Date: Sat, 10 Sep 2011 17:07:13 -0400 Subject: Reworked falling objects Previously, every type of falling object had to have its own class that defined the object type's sprite, weight, and reaction to the cart/floor. This was pretty messy considering how many object types may only be used in one game mode--for instance, the many power ups in Power mode, once it's created, will never be used outside of Power mode. So, to increase customizability and decrease class clutter, game modes now use a FallingObjectFactory to define recipes (basically a sprite filename, a weight and an identifier) that can easily be built throughout the game mode using the identifier. FallingObjectDelegate is now used for all reactions to the cart/floor, rather than defining a standard reaction in the FallingObject subclass and then putting extra stuff in FallingObjectDelegate. --- Classes/FallingObjectFactory.h | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) create mode 100644 Classes/FallingObjectFactory.h (limited to 'Classes/FallingObjectFactory.h') diff --git a/Classes/FallingObjectFactory.h b/Classes/FallingObjectFactory.h new file mode 100644 index 0000000..a861d06 --- /dev/null +++ b/Classes/FallingObjectFactory.h @@ -0,0 +1,20 @@ +// +// FallingObjectFactory.h +// Cartographic +// +// Created by Starla Insigna on 9/10/11. +// Copyright (c) 2011 Four Island. All rights reserved. +// + +#import +#import "FallingObject.h" + +@interface FallingObjectFactory : NSObject { + NSMutableDictionary* recipes; +} + +- (id)init; +- (void)createRecipeWithIdentifier:(int)identifier spriteFilename:(NSString*)filename weight:(int)weight; +- (FallingObject*)buildFallingObjectWithRecipeIdentifier:(int)identifier; + +@end -- cgit 1.4.1