blob: dfd642470065ab8779e95bc882bc26056e4850b2 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
|
//
// FallingObjectFactory.m
// Cartographic
//
// Created by Starla Insigna on 9/10/11.
// Copyright (c) 2011 Four Island. All rights reserved.
//
#import "FallingObjectFactory.h"
@interface FallingObjectRecipe : NSObject {
NSString* spriteFilename;
int weight;
}
@property (readonly) NSString* spriteFilename;
@property (readonly) int weight;
- (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight;
@end
@implementation FallingObjectRecipe
@synthesize spriteFilename, weight;
- (id)initWithSpriteFilename:(NSString*)filename weight:(int)m_weight
{
self = [super init];
if (nil != self)
{
spriteFilename = [filename retain];
weight = m_weight;
}
return self;
}
@end
@implementation FallingObjectFactory
- (id)init
{
self = [super init];
if (nil != self)
{
recipes = [[NSMutableDictionary alloc] init];
}
return self;
}
- (void)createRecipeWithIdentifier:(int)identifier spriteFilename:(NSString*)filename weight:(int)weight
{
FallingObjectRecipe* recipe = [[FallingObjectRecipe alloc] initWithSpriteFilename:filename weight:weight];
[recipes setObject:recipe forKey:[NSNumber numberWithInt:identifier]];
[recipe release];
}
- (FallingObject*)buildFallingObjectWithRecipeIdentifier:(int)identifier
{
FallingObjectRecipe* recipe = [recipes objectForKey:[NSNumber numberWithInt:identifier]];
FallingObject* object = [[FallingObject alloc] initWithSpriteFilename:recipe.spriteFilename weight:recipe.weight objectType:identifier];
return [object autorelease];
}
@end
|