Results 1 to 3 of 3

Thread: Static Camera

  1. #1
    Lesser Wizard
    Join Date
    Mar 2008
    Posts
    124

    Default Static Camera

    One of the first problems I came across when creating my first game was a way of getting the camera to a fixed position on certain levels (which are designed to be single-screen), and prevent it from following the players movement.

    To resolve the issue I placed a new object on the map, well outside of the visible playing area and attached the following script:

    Code:
    function OnInit() //run upon initialization
     
     // Stop the camera tracking the player
     GetCamera:SetEntityTrackingByID(C_ENTITY_NONE);
     
     // ooops! Because we stopped tracking the player, and we previously used
     // warp points the game reverted to the start map
     // best bring focus back to this map really!
     // remember to replace "Elevation - Easy (Level 1)" with your map name!
     GetMapManager:SetActiveMapByName("Elevation - Easy (Level 1)");
     
      // Scale and position the camera
     GetCamera:SetScale(Vector2(0.52,0.52));
     GetCamera:SetPos(Vector2(-1523.00,-230.00));
     
     
    end
    
    function OnPostInit() //run during the entity's first logic update
    
    // we don't put any code here, as the entity never gets displayed on the 
    // screen!
    
    end
    
    function OnKill() //run when removed
    
    end

    To fins out the correct values for the Vector 2 in SetPos, you need to set the screen up in the editor as you would like it displayed on screen, then bring up the console and type:

    Code:
    LogMsg (GetCamera:GetPos())
    You can get the current zoom level by clicking on "Options, Map Properties" from the editor.

  2. #2
    Squire
    Join Date
    Sep 2009
    Location
    Colorado, USA
    Posts
    25

    Default

    --- That helped... though it would not work inside of the OnInit function... (used copy/paste so syntax was correct) Had to place the code at top of the script without the function/end around it -- not sure why that worked but the OnInit function wouldn't

  3. #3
    Lesser Wizard
    Join Date
    Mar 2008
    Posts
    124

    Default

    If you have a line:

    AssignPlayerToCameraIfNeeded(this);

    then you'll need to remove it or comment it out

Similar Threads

  1. how to compile static
    By andreaszdw in forum Official ClanLib SDK Forums
    Replies: 1
    Last Post: 05-07-2007, 05:03 AM
  2. Strange static sound
    By tamaralynn in forum Dink Smallwood HD
    Replies: 1
    Last Post: 11-22-2003, 02:32 AM

Bookmarks

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •