Author Topic: Fully Restrict Camera Movement and Zoom - By the player  (Read 5706 times)

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Fully Restrict Camera Movement and Zoom - By the player
« on: May 08, 2012, 01:26:53 AM »
I would like to do this, completely restrict the Position and Zoom from the user?

Mainly because say I put SetCameraPosition(0,0) then move the screen somewhere else and then later on the code is SetCameraPosition(100,0) it won't actually go to (100,0), it will go somewhere else depending on where I move the screen, I'm guessing it's not actually coordinates? but how far to move on the x,y position?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #1 on: May 08, 2012, 02:13:58 AM »
Try using

Code: [Select]

x = 0
y = 0

while GameRunning() do

    SetCameraPosition(x,y)

end

When you want to change the position of the camera, then change the values of the variables x and y. It will make your code a lot easier to manage and you may not get the bug I think you are having.

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #2 on: May 08, 2012, 03:49:39 AM »
What about if I wanted to give the user the option to move around and that later?

Pilchard123

  • Tester
  • Old Oak
  • ****
  • Thank You
  • -Given: 4
  • -Receive: 24
  • Posts: 932
  • Eufloria: Yes
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #3 on: May 08, 2012, 04:26:39 AM »
Then put the SetCameraPosition inside an if statement.

Code: [Select]

x = 0
y = 0
cameraRestricted = true

while GameRunning() do
    if cameraRestricted then
        SetCameraPosition(x,y)
    end
end


Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #4 on: May 08, 2012, 04:58:40 AM »
thanks :) ill add that in later and get back to you!

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #5 on: May 08, 2012, 07:05:38 AM »
That doesn't seem to work at all

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #6 on: May 08, 2012, 06:20:11 PM »
What happens when you try?

You're putting this code inside function LevelLogic, right?  It won't work if you put it inside LevelSetup.

Also, it's missing a couroutine.yield()
It should be this:

Code: [Select]
function LevelLogic()
x = 0
y = 0
cameraRestricted = true

while GameRunning() do
if cameraRestricted then
SetCameraPosition(x,y)
end
coroutine.yield()
end
end

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #7 on: May 08, 2012, 06:22:17 PM »
If you want to restrict the zoom too, use something like this:


Code: [Select]
function LevelLogic()
x = 0
y = 0
cameraRestricted = true
ZoomAmount = 5

while GameRunning() do
if cameraRestricted then
SetCameraPosition(x,y)
SetCameraZoom(ZoomAmount)
end
coroutine.yield()
end
end

Tomfloria

  • Shrub
  • ***
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 232
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #8 on: May 09, 2012, 12:08:15 AM »
It will doesn't work Annikk, It must be an iPad limitation.

annikk.exe

  • Achiever
  • Ent
  • ****
  • Thank You
  • -Given: 0
  • -Receive: 4
  • Posts: 1,809
Re: Fully Restrict Camera Movement and Zoom - By the player
« Reply #9 on: May 14, 2012, 11:54:45 PM »
If you try loading up the level Extreme Pwn Laz0rs, that should restrict your view.  Try zooming out.  You might notice during the first minute, the amount you can zoom out is gradually increasing.  Do you get that on your iPad?  If so, what you are trying to do is possible after all. :>