Developing a simple game without using game engines?

I am trying to develop a simple football game, including a penalty , in which I have to animate the ball from player to goal ... I used to be using simple animations, using a timer to add a ball image to the axis so that it moves from 1 point to another. But I didn’t have the desired result, because the animation was not so smooth ... Therefore, I thought about using the Game Engine ... Since I am a New Programmer , I have no idea about the game engine, and I also can’t find suitable documentation for engines like box2d or chipmunks or sparrow .. I also thought about using UIView animations instead of earlier animations, since I think you can achieve a much better animation without scratching my head, trying to work on the game engine .... I'm not going there with this, so it would be really cool if someone could refresh this problem of mine.

+3
source share
2 answers

Use UIView animations, for example in:

[UIView beginAnimations:nil context:NULL];
[UIView setAnimationDuration:0.3]; // or whatever time
object.center=CGPointMake(object.center.x+2, object.center.y+4);
// or whatever
[UIView commitAnimations];

You should also use NSTimer at the same interval so that you can seamlessly trigger animations.

NSTimer *timer=[NSTimer scheduledTimerWithTimeInterval:0.3 target: self 
selector:@selector(animation) userInfo: nil repeats: YES];

Then we implement the method:

- (void)animation {
    [UIView beginAnimations:nil context:NULL];
    [UIView setAnimationDuration:0.3]; // or whatever time
    object.center=CGPointMake(object.center.x+5, object.center.y+7);
    // or whatever
    [UIView commitAnimations];    
}

This should make for ANY simple game.

+2
source

cocos2d, , . CCSprites , , . https://github.com/haqu/tweejump.

onEnter   [self scheduleUpdate]

update:,

- (void)update:(ccTime)dt {
    ball_pos.x += ball_velocity.x * dt;
    ball_pos.y += ball_velocity.y * dt;
    ball_velocity.x += ball_acc.x * dt;
    ball_velocity.y += ball_acc.y * dt;

    //game logic goes here (collision, goal, ...)

    ball.position = ball_position;
}

. ball_pos, ball_velocity ball_acc vvCertex2F.

, , , , - ( ).

, , . ,

0

Source: https://habr.com/ru/post/1763796/


All Articles