Friday, 16 August 2013

XCode: how to position sprite on top of other sprites?

XCode: how to position sprite on top of other sprites?

My spaceship is currently in back of the stars and enemy ships, and so
these objects appear to pass through the spaceship. Is it possible to
place the spaceship in "front" of these objects within my viewDidLoad?
- (void)viewDidLoad
{
[super viewDidLoad];
self.context = [[EAGLContext alloc]
initWithAPI:kEAGLRenderingAPIOpenGLES2];
if (!self.context) {
NSLog(@"Failed to create ES context");
}
GLKView *view = (GLKView *)self.view;
view.context = self.context;
[EAGLContext setCurrentContext:self.context];
self.effect = [[GLKBaseEffect alloc] init];
GLKMatrix4 projectionMatrix = GLKMatrix4MakeOrtho(0, 480, 0, 320, -1024,
1024);
self.effect.transform.projectionMatrix = projectionMatrix;
//////////////PLAYER INFO///////////////
self.player = [[SGGSprite alloc] initWithFile:@"Player.png"
effect:self.effect];
self.player.position = GLKVector2Make(self.player.contentSize.width/2,
160);
self.children = [NSMutableArray array];
[self.children addObject:self.player];
UITapGestureRecognizer *tapRecognizer = [[UITapGestureRecognizer alloc]
initWithTarget:self action:@selector(handleTapFrom:)];
[self.view addGestureRecognizer:tapRecognizer];
self.projectiles = [NSMutableArray array];
self.targets = [NSMutableArray array];
ammo.text = @"Ammo: 30";
}

No comments:

Post a Comment