Ignore:
Timestamp:
08/04/10 16:03:31 (9 years ago)
Author:
domtron_vox
Message:

Patch by domtron_vox.
-added the ability to scroll the screen when the cursor is at an edge.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • trunk/game/scripts/gamesceneview.py

    r604 r620  
    1818from sounds import SoundEngine 
    1919from viewbase import ViewBase 
     20from fife import fife 
    2021 
    2122class GameSceneView(ViewBase): 
     
    130131                self.highlight_obj = None   
    131132            
     133 
     134    def moveCamera(self, direction): 
     135        """Move the camera in the given direction. 
     136        @type direction: list of two integers 
     137        @param direction: the two integers can be 1, -1, or 0 
     138        @return: None """   
     139         
     140        if 'cameras' in dir(self.model.active_map): 
     141            cam = self.model.active_map.cameras[self.model.active_map.my_cam_id] 
     142            location = cam.getLocation() 
     143            position = location.getMapCoordinates() 
     144             
     145            #how many pixls to move by each call 
     146            move_by = 1 
     147            #create a new DoublePoint3D and add it to position DoublePoint3D 
     148            new_x, new_y = move_by * direction[0], move_by * direction[1] 
     149 
     150            position_offset = fife.DoublePoint3D(int(new_x), int(new_y)) 
     151            position += position_offset 
     152             
     153            #give location the new position 
     154            location.setMapCoordinates(position) 
     155 
     156            #detach the camera from any objects 
     157            cam.detach() 
     158            #move the camera to the new location 
     159            cam.setLocation(location) 
     160             
     161             
Note: See TracChangeset for help on using the changeset viewer.