Author Topic: [SOLVED] FlxG follow...why doesn't it follow?  (Read 2736 times)

Daranus

  • Member
  • **
  • Posts: 5
  • Karma: +0/-0
    • View Profile
[SOLVED] FlxG follow...why doesn't it follow?
« on: Sun, Jul 10, 2011 »
Hey fellas, it's me, once again.


First of all, my Code:
init:
Code: [Select]
    [FlxU setWorldBoundsWithParam1:0 param2:0 param3:100 param4:100];
    focus = [[[FlxObject alloc] initWithX:player.x y:player.y width:1 height:1] autorelease];
    [FlxG followWithParam1:focus param2:15];
    [FlxG followBoundsWithParam1:0 param2:0 param3:stageLength param4:5000 param5:TRUE];
    [FlxG followAdjustWithParam1:0 param2:0];

update:
Code: [Select]
    focus.x =  player.x + 200;
    focus.y =  player.y;
And here is another question:

How can I achieve, that the camera does not only follow in the x direction, but follows equally in the y direction?!...I think not the following itself is the problem, as it follows when the y speed of the player is not that high. But when i do a quick jump, the focus should jump up as well. At the moment, the player jumps out of the screen and comes back in.

How can I do that?

Thanks in advance fellas,
Daranus

Edit: Maybe i got the issue...as i start at position 0,0 it could be that you cannot go into the -y direction?...have to try lowering it from the beginning..

Edit 2: That was it. The camera cannot follow into a -ysomething value. (yes,kinda funny to solve a problem before the post has been approved..l)
« Last Edit: Sun, Jul 10, 2011 by Daranus »

tokyotron

  • Member
  • **
  • Posts: 27
  • Karma: +0/-0
    • View Profile
Re: [SOLVED] FlxG follow...why doesn't it follow?
« Reply #1 on: Tue, Jul 24, 2012 »
Some of the functions in FlixeliOS have undescriptive parameters (maybe a problem caused by something that ported the code).

I tried to change up some of that to make the code more legible awhile back.
Looking at my code now for this section this is probably what would help you:
Code: [Select]
[FlxG followBoundsWithParam1:0 param2:0 param3:stageLength param4:5000 param5:TRUE];
does really mean

Code: [Select]
[FlxG followBoundsWithMinX:0 minY:0 maxX:INT_MAX maxY:320];
Hmm ok one parameter less but you get the idea. Change the 2nd parameter (param2) to a negative value and then you can have it follow negative Y values.

I did have follow negative X values and know it works, although I never tried negative Y values.
« Last Edit: Tue, Jul 24, 2012 by tokyotron »