//
//  GameObject.m
//  Caterpillar
//
//  Created by Brandon Trebitowski on 11/13/11.
//  Copyright (c) 2011 __MyCompanyName__. All rights reserved.
//

#import "GameObject.h"

@implementation GameObject
@synthesize sprite = _sprite;
@synthesize gameLayer = _gameLayer;
@synthesize position = _position;

- (void)dealloc {
    [_sprite release];
    [super dealloc];
}

- (id)initWithGameLayer:(GameLayer *)layer {
    if(self = [super init]) {
        self.gameLayer = layer;
    }
    return self;
}

// 1
- (void) setPosition:(CGPoint)position {
    _position = position;
    _sprite.position = position;
}

// 2
- (CGRect)getBounds {
    CGSize size = [self.sprite contentSize];
    return CGRectMake(self.position.x - size.width * self.sprite.anchorPoint.x, 
                      self.position.y - size.height * self.sprite.anchorPoint.y, 
                      size.width, size.height);
}

@end

