Class Camera


  • public class Camera
    extends greenfoot.World
    This is the Camera class. It is the central part of the camera package as it runs the background world and displays the things on screen. It extends the World class. Camera is currently in development. Splitscreen support is planned and you will find some parts of code of that but it does not do anything yet.
    Version:
    0.2.1
    Author:
    RcCookie
    • Constructor Summary

      Constructors 
      Constructor Description
      Camera​(int width, int height, int camNum, double scale, greenfoot.World world, int[] locX, int[] locY)
      Constructs a new World of type Camera that displayes an area of the given size centered onto the given coordinates
      Camera​(int width, int height, int camNum, double scale, greenfoot.World world, greenfoot.Actor[] host)
      Constructs a new World of type Camera that displayes an area of the given size following the given actor.
      Camera​(greenfoot.World world, int locX, int locY)
      Constructs a new World of type Camera that displayes an area of 600 time 400 pixels centered onto the given coordinates
      Camera​(greenfoot.World world, greenfoot.Actor host)
      Constructs a new World of type Camera that displayes an area of 600 time 400 pixels of view range of the given world following the given actor
    • Method Summary

      All Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      void act()
      Runs the main world without showing it and displays the actors at their relative positions.
      Camera lookAt​(int[] locX, int[] locY)
      Activates and returns a new Camera that looks at the given coordinates with the old amount of screens and based on old settings.
      Camera lookAt​(int locX, int locY)
      Activates and returns a new Camera that looks at the given coordinates based on old settings.
      Camera lookAt​(greenfoot.Actor a)
      Activates and returns a new Camera that looks at the given actor based on old settings.
      Camera lookAt​(greenfoot.Actor[] a)
      Activates and return a new Camera that looks at the given actors in splitscreen with the old amount of screens and old settings.
      • Methods inherited from class greenfoot.World

        addObject, getBackground, getCellSize, getColorAt, getHeight, getObjects, getObjectsAt, getWidth, numberOfObjects, removeObject, removeObjects, repaint, setActOrder, setBackground, setBackground, setPaintOrder, showText, started, stopped
      • Methods inherited from class java.lang.Object

        clone, equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • Camera

        public Camera​(greenfoot.World world,
                      greenfoot.Actor host)
        Constructs a new World of type Camera that displayes an area of 600 time 400 pixels of view range of the given world following the given actor
        Parameters:
        world - The world the camera should display
        host - The actor the camera should follow
      • Camera

        public Camera​(greenfoot.World world,
                      int locX,
                      int locY)
        Constructs a new World of type Camera that displayes an area of 600 time 400 pixels centered onto the given coordinates
        Parameters:
        world - The world the camera should display
        locX - The x position of the world the camera should look at
        locY - The y position of the world the camera should look at
      • Camera

        public Camera​(int width,
                      int height,
                      int camNum,
                      double scale,
                      greenfoot.World world,
                      int[] locX,
                      int[] locY)
        Constructs a new World of type Camera that displayes an area of the given size centered onto the given coordinates
        Parameters:
        width - The cameras screen width
        height - The cameras screen height
        camNum - WIP The number of cameras for splitscreen (Does nothing!)
        scale - WIP the zoom that the camera shows objects with
        world - The world the camera should display
        locX - The x position of the world the camera should look at
        locY - The y position of the world the camera should look at
      • Camera

        public Camera​(int width,
                      int height,
                      int camNum,
                      double scale,
                      greenfoot.World world,
                      greenfoot.Actor[] host)
        Constructs a new World of type Camera that displayes an area of the given size following the given actor.
        Parameters:
        width - The cameras screen width
        height - The cameras screen height
        camNum - WIP The number of cameras for splitscreen (Does nothing!)
        scale - WIP the zoom that the camera shows objects with
        world - The world the camera should display
        host - WIP The actors each camera should follow (Only first is used!)
    • Method Detail

      • act

        public void act()
        Runs the main world without showing it and displays the actors at their relative positions.
        Overrides:
        act in class greenfoot.World
      • lookAt

        public Camera lookAt​(greenfoot.Actor a)
        Activates and returns a new Camera that looks at the given actor based on old settings.
        Parameters:
        a - The actor to look at
        Returns:
        The new Camera
      • lookAt

        public Camera lookAt​(greenfoot.Actor[] a)
        Activates and return a new Camera that looks at the given actors in splitscreen with the old amount of screens and old settings.
        Parameters:
        a - The actors to look at
        Returns:
        The new Camera
      • lookAt

        public Camera lookAt​(int locX,
                             int locY)
        Activates and returns a new Camera that looks at the given coordinates based on old settings.
        Parameters:
        locX - The x-coordinate to look at
        locY - The y-coordinate to look at
        Returns:
        The new camera
      • lookAt

        public Camera lookAt​(int[] locX,
                             int[] locY)
        Activates and returns a new Camera that looks at the given coordinates with the old amount of screens and based on old settings.
        Parameters:
        locX - The x-coordinates to look at
        locY - The y-coordinates to look at
        Returns:
        The new camera