Adding New Build to iPhone??

Can anyone explain this to me in plain English? I want to create my own 'Test game' Please.......

ALL SORTED!!
1. I'm guessing cp is the unix copy command, to copy VerticalStack.h to Foo.h...basically creating a new file Foo.h with the contents of VerticalStack.h.
Do a Finder search for VerticalStack and see where it is.
Same thing for g_TestEntries, use Finder search. Or Xcode Find.
beeOh wrote:
1. I'm guessing cp is the unix copy command, to copy VerticalStack.h to Foo.h...basically creating a new file Foo.h with the contents of VerticalStack.h.
Do a Finder search for VerticalStack and see where it is.
Same thing for g_TestEntries, use Finder search. Or Xcode Find.



Oh sorry, did that, got it all running now!! Looks great! but i have a problem,

Is there a code for the camera to follow say a ball on screen? All i can see as to the camera position is this code:
Code:
   b2BodyDef bd;
               
               float32 x = 0.0f;
               //float32 x = RandomFloat(-0.02f, 0.02f);
               //float32 x = i % 2 == 0 ? -0.025f : 0.025f;
               bd.position.Set(xs[j] + x, 0.752f + 1.54f * i);
               b2Body* body = m_world->CreateBody(&bd);
               
               body->CreateShape(&sd);
               body->SetMassFromShapes();


Any idea how i get the camera to follow where i go?
Anyone?
Hi That code is not related to the camera position, only the object position. If you are making your own stuff it could be a nice idea to abstract the camera and let it have its own class that you can position.

In the demo, positionoffset controls the camera position.

Try looking at
Code:
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
in Box2dView

if you want the camera to follow an object you have to set this positionoffset to match the position of the ball ( or whatever object) in each loop.

Hope this helps.
skrekkur wrote:
Hi That code is not related to the camera position, only the object position. If you are making your own stuff it could be a nice idea to abstract the camera and let it have its own class that you can position.

In the demo, positionoffset controls the camera position.

Try looking at
Code:
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
in Box2dView

if you want the camera to follow an object you have to set this positionoffset to match the position of the ball ( or whatever object) in each loop.

Hope this helps.



Oh ok i see, i am only learning about this stuff and its trial and error, mostly error... 🙁

This is the code i have right now,
Code:
- (void) touchesMoved:(NSSet*)touches withEvent:(UIEvent*)event
{
   for (UITouch *touch in touches)
   {
      CGPoint touchLocation=[touch locationInView:self];
      CGPoint worldPosition=[self screenSpaceToWorldSpace:touchLocation];
      //printf("Screen touched %f,%f -> %f,%f\n",touchLocation.x,touchLocation.y,worldPosition.x,worldPosition.y);
      
      
      CGPoint screenDistanceMoved=CGPointMake(touchLocation.x-lastScreenTouch.x,touchLocation.y-lastScreenTouch.y);
      if (panning)
      {
         screenDistanceMoved.x/=160;
         screenDistanceMoved.y/=160;
         screenDistanceMoved.x*=sceneScale;
         screenDistanceMoved.y*=-sceneScale;
         positionOffset.x+=screenDistanceMoved.x;
         positionOffset.y+=screenDistanceMoved.y;
      }
      
      lastScreenTouch=touchLocation;
      lastWorldTouch=worldPosition;
      test->MouseMove(b2Vec2(lastWorldTouch.x,lastWorldTouch.y));
      
   }


So how do i change that to follow say a circle on screen (a ball)? Do i need to change positionOffset.x+=screenDistanceMoved.x;positionOffset.y+=screenDistanceMoved.y; ?? and how do i find the position of my ball to put that in? or do you have to link it to the object?

Thank you for the reply though...

Original thread: https://box2d.org/forum/viewtopic.php?t=3877