Camera Position Problem

betazerobetazero Member Posts: 39
edited November -1 in Working with GS (Mac)
I have tried several ways but here is my problem. I constrain the camera to the x & y mouse position ( my actors position is also constrained to the x & y mouse position ) but once my actor gets to about 240,160, the position of the mouse (finger) starts offsetting from where the actor is. It works fine in the editable preview , but not when it just shows the 480,320 view. Also the iphone preview is messed up. What am I doing wrong? I tried using the accelerometer to move the camera but I have the same problem.

Comments

  • betazerobetazero Member Posts: 39
    Can someone please help. I am trying to make a larger map but this is preventing my production. I hope i am just doing some small thing wrong. I use the mouse(touch) to control the main actor( constrained x & y to mouse x & y ). As soon as i move the actor which controls the camera past 240,160, the mouse is no longer centered on my main actor. It gets further and further away the farther i pan across the map. When I preview on screen where it shows my full screen size it seems to function right . As soon as i switch to what you will actually see on an iphone (480,320 confined), it is messed up. Please Please help! I will give out free candy and ice cream :)

    By the way to the developers of GameSalad...Thank you Soooooooooooo much!!!! I have all these game ideas stuck in my head and now I can get them out!
  • firemaplegamesfiremaplegames Member Posts: 3,211
    Instead of constraining the camera to the player's x and y, you could simply add a Control Camera behavior to the player. that way the camera will always be locked to the player...
  • betazerobetazero Member Posts: 39
    I have tried but I have the same results.

    Here I posted a quick example of the problem. Move the actor to the right. Once it starts to pan the mouse runs away from the actor.

    http://gamesalad.com/game/play/35790
  • rebumprebump Member Posts: 1,058
    (kind of an overkill proof but at least it verifies things are moving appropriately)

    The mouse runs away because it is moving in your desktop. Add an actor (and an instance of it in the scene) that uses only the "display text" behavior to display "device.mouse.x". Now place the Orange actor (Actor 1) so the instance in the scene has an X position of 0 (it should be halfway on the left edge). Then "Preview". You will see as you move right from the left side of the preview window (where the mouse X values start at 0) that when you get to the right edge of the preview window, the mouse X position is 480 (the width of the window). Then as you move further right past the right edge you approach 960 (the width of the scene). As you hit 960, your mouse pointer will be as far away from the right edge as the width of the window (i.e. your mouse truly traveled 960 pixels). However, since the Orange actor is limited to the camera view, the last 480 pixels scroll past leaving the Orange actor "in place" relative to the camera view.

    It is kind of an optical illusion...more of a logic illusion if you will. You may be able to scale the mouse movement but then you may lose some precision in movement.
  • betazerobetazero Member Posts: 39
    Yea I see what you mean with the mouse X text. Mine goes off center at 270 ( weird number in my opinion ..) pixels and then hits the right side directly at 480. Does anyone know of a workaround for this?

    edit - Actually it goes off center at 272 pixels...even weirder number.

    edit - The 272 changes as I change the camera constraint box.
  • rebumprebump Member Posts: 1,058
    Yeah, the constraint box affects when it scrolls. I think I had set it to the width of the entire camera view (not the whole scene...which you couldn't anyway). I also, if you recall, moved the orange actor to 0 for position X (i.e. the left side of the screen so it was half-way visible...the actor's center is where position X/Y come from).

    Then you will see it scroll from 0 to 479 and then 480 to 959+ as you scroll out of the camera view/game window.
  • betazerobetazero Member Posts: 39
    Anyone know a solution to this problem?
  • betazerobetazero Member Posts: 39
    found out how to do it. Just in case you wanted to know here is the solution. The one actor grabs the camera origin offset.

    cya and thanks for helping.

    http://gamesalad.com/game/play/36003
  • rebumprebump Member Posts: 1,058
    Good catch. Thanks for mentioning you found the answer on the GS site. I looked and there it was (and it is quite a little trick):

    http://gamesalad.com/wiki/how_tos:gsc_drag_and_drop_movement#modifications_for_non-default_scene_size
Sign In or Register to comment.