Applications and Screens

Application | Screen

 

Application
managed singleton class : Object
  • DESCRIPTION
    • Class Application is the starting point for a Plasmacore game and contains many of the methods and properties related to the appearance and control of the overall app.
    • Your custom app should extend Application ("class SweetApp : Application") and at the least instantiate a Screen object to provide a game view (see the example program generated when you build a new project).
    • Application properties and methods you may be interested in include:
      • - Setting the bg_color the screen is cleared to.
      • - Setting the clipping_region to restrict drawing.
      • - Setting the window title, fullscreen mode, or mouse visibility.
      • - Setting the draw target (main buffer or offscreen buffer).
      • - Overriding the handling of on_exit_request.
  • PROPERTIES
    • display_size : readOnly Vector2
      • The display size in pixels. In general use your main screen's "size" instead.
    • bg_color : Color
      • The color the screen is automatically cleared to before each call to draw(). If you set 'bg_color' to a color with zero alpha the native layer will not clear the back buffer.
    • clipping_region : Box
      • The current viewport - parts of graphics that lie outside this region are clipped and not drawn.
    • trace_messages : String[]
      • Internal use - the list of active trace messages.
    • last_trace_activity_ms : Int64
      • Internal use - the time of the last new trace message.
  • METHODS
    • init_object()
      • need to set this up first in case of error messages
    • init()
    • call_init(Vector2 init:display_size)
    • title(String window_title) : native
      • Application title property-set for this application.
      • Example:
          Application.window_title = "MadStone"
        
    • fullscreen().Logical : native
      • Returns "true" if the application is running in fullscreen mode or "false" if it's running in windowed mode.
      • Example:
          if (Application.fullscreen) ...
        
    • fullscreen(Logical setting) : native
      • Sets the application to fullscreen if setting is "true" or windowed mode if it's "false".
      • Example:
          Application.fullscreen = true
        
    • mouse_visible(Logical setting) : native
      • Property-set that specifies the visibility of the system mouse. This is "true" by default.
      • Example:
          Application.mouse_visible = false
        
    • input_capture(Logical setting) : native
      • Property-set that specifies whether input is captured by (and restricted to) this application. This is "false" by default.
      • Example:
          Application.input_capture = true
        
    • on_exit_request()
      • Called when the user attempts to close the app. Calls exit_program() by default.
      • Windows and Mac: You can override this method to perform cleanup and/or postpone the call to exit_program at some later point.
      • iPhone: You cannot prevent the application from exiting; use this method to save game state in a file if desired.
    • on_toggle_fullscreen()
      • Called by the input object when an ALT+ENTER key combination is detected. The default behavior is to toggle the fullscreen property setting.
    • trace(String mesg)
      • Prints the given trace message to the screen as well as logging it to "log.txt".
    • trace(Vector2 v)
      • Traces 'v' as a text message.
    • log(String mesg) : native
      • Prints the given message to stdout and "save/log.txt".
    • log(Vector2 v)
      • Logs 'v'.
    • display_region().Box
    • clipping_region(Box new_clip)
      • This property-set adjust the clipping region of the screen. Anything part of any graphics that lie outside the clipping region won't be drawn. The current transform is applied to the clipping coordinates - a non-orthagonal transform will not be correctly applied.
    • set_draw_target(OffscreenBuffer buffer[,Logical blend_alpha])
      • Selects the given offscreen buffer as the target of various drawing commands - send "null" to change back to the main display. Send "true" for 'blend_alpha' to perform normal alpha blending or "false" to preserve the alpha of the original colors as they're drawn.
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods

 

Screen
class : View
  • DESCRIPTION
    • A Screen is a View that fills (or overlays) the entire display.
    • Typically you'll create a single Screen subclass as a deferred singleton and reference it from your application's init() method, at which point it will automatically have its update() method called 60 times a second and its draw() method called up to 60 times a second (see the example program generated when you build a new project).
    • Because a Screen is also a GenericImage, you can set its angle, position, handle, and scale as desired (good for earthquake effects). For iPhone and Android you can also call orient_right, orient_up, etc. to set these properties appropriately.
    • A screen receives mouse, keyboard, and acceleration events (when possible) through the methods on(MouseEvent), on(KeyEvent), and on(AccelerationEvent). Input state may also be accessed through the Input singleton with the exception of mouse_position:Vector2, which must be a Screen property because its position depends on the current screen angle, etc.
  • PROPERTIES
    • size : Vector2
      • The nominal size of the given image, in pixels. Change 'size' if you want the image's standard size to be a given number of pixels or change 'scale' if you want the image to be proportionally larger or smaller.
    • scale : Vector2
      • The size multiplier for rendering, (1.0,1.0) by default. Setting "scale = Vector2(2.0,0.5)" would cause the image to render at twice the width and half the height. Change 'size' instead if you want to achieve particular pixel dimensions.
    • handle : Vector2
      • Specifies the drawing and rotation origin of this image. This can be set to a pixel value relative to the upper-left of the image (0,0) or a Handle category such as "Handle.center" or "Handle.bottom_center". The handle is the top-left corner (0,0) by default.
    • color : Color
      • The multiplier for each pixel in this image as it's drawn. The default color of Color(255,255,255,255) ensures that the image will appear "normal". A color of Color(255,255,0) would not draw any of the blue channel, making a grey-scale image appear to be tinted yellow. A color of Color(255,255,255,128) would draw the image halfway transparent.
    • render_flags : Render
      • Any combination of Render constants, or 0 for no special rendering options.
      • Example:
          ghost.render_flags = (Render.overexpose | Render.fixed_color)
        
    • blend : Blend
      • Blending mode. See class BlendManager for more examples.
    • angle : Radians
      • The angle property variable. This may be set to a new Radians or Degrees value.
    • hflip : Logical
      • Specifies that an image should be flipped horizontally when drawn. This mirroring is applied before the image is rotated and does not affect the spatial positioning.
    • vflip : Logical
      • Specifies that an image should be flipped vertically when drawn. This mirroring is applied before the image is rotated and does not affect the spatial positioning.
    • alpha : Int32
      • Internal use. Prevents 'alpha' from being declared again by mistake and being intercepted by access methods.
    • parent : Panel
      • The parent Panel of this component.
    • position : Vector2
      • The position this component is drawn at.
    • screen_to_view : Transform
      • Internal use - used to transform raw mouse positions into screen coordinates.
    • active : Logical
      • When "true" this component receives messages (including calls to update() and draw()) normally.
    • components : Component[]
      • A list of child components contained in this Panel.
    • input_listeners : InputListener[]
      • List of key listeners receiving events from this dispatcher.
    • mouse_position : Vector2
      • The current mouse position relative to this view.
  • METHODS
    • init_object()
    • init()
    • orient_up().Screen
      • Sets the screen transformation so that the top of the screen is at the top of your display at its standard orientation.
    • orient_down().Screen
      • Sets the screen transformation so that the top of the screen is at the bottom of your display at its standard orientation.
    • orient_right().Screen
      • Sets the screen transformation so that the top of the screen is at the right side of your display at its standard orientation.
    • orient_left().Screen
      • Sets the screen transformation so that the top of the screen is at the left side of your display at its standard orientation.
    • push_transform()
      • Internal use.
    • pop_transform()
      • Internal use.
    • hash_code().Int32
    • create_duplicate().Object
    • to_String().String
    • op==(Object other).Logical {multimethod}
    • op<>(Object other).Logical {multimethod}
    • type_name().String : native
    • runtime_type().RuntimeType : native
    • runtime_properties().RuntimeProperties
    • runtime_methods().RuntimeMethods
    • handle(Vector2 new_handle)
    • handle(Handle h)
    • angle(Radians new_angle)
    • angle(Degrees deg)
    • scale(Vector2 new_scale)
    • scale(Real64 uniform_scale)
    • point_filter(Logical setting)
    • point_filter().Logical
    • fixed_color(Logical setting)
    • fixed_color().Logical
    • texture_wrap(Logical setting)
    • texture_wrap().Logical
    • alpha().Int32
    • alpha(Int32 new_alpha)
    • bounding_box().Box
    • bounding_circle().Circle
    • draw(Real64 x,Real64 y)
    • clear([Color c])
    • release()
    • on(KeyEvent event)
    • on(MouseEvent event)
    • on(JoystickEvent event)
    • on(AccelerationEvent event)
    • on(SystemEvent event)
    • listen_to(DispatcherType dispatcher)
    • stop_listening_to(DispatcherType dispatcher)
    • init(Panel init:parent)
    • draw(Vector2 init:position)
    • draw()
    • update()
    • fill(Color c)
    • bring_to_front()
    • draw-inner()
    • dispatch(KeyEvent event)
    • dispatch(MouseEvent event)
    • dispatch(JoystickEvent event)
    • dispatch(AccelerationEvent event)
    • dispatch(SystemEvent event)
    • input_listeners().InputListener[]
    • input_listeners(InputListener[] input_listeners.1232)
    • active_input_listeners().InputListener[]
    • active_input_listeners(InputListener[] active_input_listeners.1233)