LimitCamera
LimitCamera CameraIndex, Flag
 
Parameters:

    CameraIndex = The index of the camera you wish to limit
    Flag = On / Off flag to toggle to auto limit this cameras movement
Returns: NONE
 

      LimitCamera when enabled will limit cameras movement to within a user defined region. You can define the actauly region by using the LimitCameraBounds command.



FACTS:


      * By default camera limiting is turned off when a camera is created.

      * When camera limiting is enabled, the camera can not move outside the bounds of the region defined by the LimitCameraBounds command




Mini Tutorial:


      This example creates a camera, then limits it's movement to within a region. The main DO/Loop allows the user to move the camera around, while being limited to the users defined movement region


  
; create camera 1.  Which will attach itself to
; the current surface, which will be the screen
; by default
  CreateCamera 1
  
; LImit the Cameras Movement To -100x,-100y, And 2100x, 2100y
  
  LimitCamera 1,true
  LimitCameraBounds 1,-100,-100,2100,2100
  
; Now redirect All gfx output to the Scene buffer, so the
; camera  has something To view.
  CaptureToScene
  
; draw some random gfx to the screen buffer
  For lp=0 To 50
     x=Rnd(2000)
     y=Rnd(2000)
     Size=Rnd(50)
     
     Select Rnd(1)
         Case 0
           ; draw a circle to the Scene
             CircleC x,y,size,1,RndRGB()
         Case 1
           ; draw a box to the Scene
             BoxC x,y,x+size,y+size,1,RndRGB()
     EndSelect
  Next
  
; Tell PB to retutrn to drawing GFX immediately
  DrawGFXImmediate
  
; Start a Do /loop
  Do
     
   ; Arrows to control camera
     If UpKey() Then MoveCamera 1,0,-5
     If DownKey() Then MoveCamera 1,0,5
     If LeftKey() Then MoveCamera 1,-5,0
     If RightKey() Then MoveCamera 1,5,0
     
   ; Draw the camera and whatever it can see from the
   ; scene buffer
     DrawCamera 1
     
   ; Display message
     SetCursor 0,0
     Print "Arrows to Move this camera"
     Print "Camera Xpos"+Str$(GetCameraX(1))
     Print "Camera Ypos"+Str$(GetCameraY(1))
     
   ; Show the user the screen.
     Sync
   ; Loop back to the DO statement
  Loop
  




This example would output.

  
  
  

 
Related Info: GetCameraLimitX1 | GetCameraLimitX2 | GetCameraLimitY1 | GetCameraLimitY2 | LimitCameraBounds | MoveCamera | PositionCamera | PositionCameraX | PositionCameraY :
 


(c) Copyright 2002 - 2024 - Kevin Picone - PlayBASIC.com