I started a platform game in spriteKit and I have a little problem with landscape mode. When I make a jump with my hero, I use
-(void)touchesBegan:(NSSet *)touches withEvent:(UIEvent *)event
and while the hero is in the air and collides with a wall or any object and misses its speed, I use
-(void)touchesMoved:(NSSet *)touches withEvent:(UIEvent *)event
{
UITouch *touch = [touches anyObject];
CGPoint positionInScene = [touch locationInNode:self];
SKSpriteNode *touchedNode = (SKSpriteNode *)[self nodeAtPoint:positionInScene];
CGPoint posicionHero = [self.world childNodeWithName:@"hero"].position;
SKSpriteNode *touchHero = (SKSpriteNode *)[self nodeAtPoint:posicionhero];
if ((touchedNode != touchHero)
&&
(positionInScene.x > [self.world childNodeWithName:@"hero"].position.x))
{
[[self.world childNodeWithName:@"hero"].physicsBody applyImpulse:CGVectorMake(5, 0)];
}
if ((touchedNode != touchHero)
&&
(positionInScene.x < [self.world childNodeWithName:@"hero"].position.x))
{
[[self.world childNodeWithName:@"hero"].physicsBody applyImpulse:CGVectorMake(-5, 0)];
}
}
.
, , , , , , , , , . , . , .