bittyBIG Dynamic Camera System
Interactive documentation, glossary, examples, and viewport tester

Dynamic Camera System

The bittyBIG Dynamic Camera System gives Stencyl projects a more flexible camera and output pipeline. It supports zoom, tweening, split-screen, picture-in-picture, viewport transforms, camera rotation, screenshake, and pixel-perfect display behavior.

Quick Start

This is the shortest useful setup: initialize the system, create a camera, and center it on the player.

Initialize bittyBIG Dynamic Camera System
Create Camera ID 0
Set Camera Center to Actor player for Camera ID 0
Tip: Use Set Camera Size when you want to change how much of the game scene is viewed on the screen. For example, a 320x180 camera on a 1920x1080 canvas gives a clean 6x pixel-perfect view.

Common Setups

These examples use a 1920x1080 canvas. Use Set Camera Size when you want to control how much of the game scene is viewed inside that layout.

Full-screen pixel-perfect camera

Use this when one camera fills the full 1920x1080 canvas. A 320x180 camera gives a clean 6x view.

Initialize bittyBIG Dynamic Camera System
Create Camera ID 0
Set Camera to Width 320 Height 180 for Camera ID 0
Set Camera Center to Actor player for Camera ID 0
Equivalent code
scripts.BittyCameraSystem.init();

scripts.BittyCameraBlocks.createCamera(0);
scripts.BittyCameraBlocks.setCameraSize(320, 180, 0);
scripts.BittyCameraBlocks.setCameraCenterToActor(player, 0);

Two-player left/right split screen

For a 1920x1080 canvas, each half is 960x1080. A 160x180 camera gives each viewport a clean 6x scale.

Initialize bittyBIG Dynamic Camera System
Create Camera ID 0
Create Camera ID 1
Set Viewport ID 0 to X 0 Y 0 Width 960 Height 1080
Set Viewport ID 1 to X 960 Y 0 Width 960 Height 1080
Set Camera to Width 160 Height 180 for Camera ID 0
Set Camera to Width 160 Height 180 for Camera ID 1
Equivalent code
scripts.BittyCameraSystem.init();

scripts.BittyCameraBlocks.createCamera(0);
scripts.BittyCameraBlocks.createCamera(1);

scripts.BittyCameraBlocks.setDisplayPortRect(0, 0, 0, 960, 1080);
scripts.BittyCameraBlocks.setDisplayPortRect(1, 960, 0, 960, 1080);

scripts.BittyCameraBlocks.setCameraSize(160, 180, 0);
scripts.BittyCameraBlocks.setCameraSize(160, 180, 1);

Picture-in-picture camera

Use one main camera and one smaller overlay camera. This example uses a full 1920x1080 main viewport with a 440x248 overlay.

Initialize bittyBIG Dynamic Camera System
Create Camera ID 0
Create Camera ID 1
Set Viewport ID 0 to X 0 Y 0 Width 1920 Height 1080
Set Viewport ID 1 to X 1440 Y 40 Width 440 Height 248
Set Camera to Width 320 Height 180 for Camera ID 0
Set Camera to Width 110 Height 62 for Camera ID 1
Equivalent code
scripts.BittyCameraSystem.init();

scripts.BittyCameraBlocks.createCamera(0);
scripts.BittyCameraBlocks.createCamera(1);

scripts.BittyCameraBlocks.setDisplayPortRect(0, 0, 0, 1920, 1080);
scripts.BittyCameraBlocks.setDisplayPortRect(1, 1440, 40, 440, 248);

scripts.BittyCameraBlocks.setCameraSize(320, 180, 0);
scripts.BittyCameraBlocks.setCameraSize(110, 62, 1);

Smaller Display Area

For a smaller centered-style setup, use a 1440x810 Display Area. Left/right halves are 720x810.

Initialize bittyBIG Dynamic Camera System
Set Display Area to X 0 Y 0 Width 1440 Height 810
Set Viewport ID 0 to X 0 Y 0 Width 720 Height 810
Set Viewport ID 1 to X 720 Y 0 Width 720 Height 810
Equivalent code
scripts.BittyCameraSystem.init();

scripts.BittyCameraBlocks.setGameAreaRect(0, 0, 1440, 810);

scripts.BittyCameraBlocks.createCamera(0);
scripts.BittyCameraBlocks.createCamera(1);

scripts.BittyCameraBlocks.setDisplayPortRect(0, 0, 0, 720, 810);
scripts.BittyCameraBlocks.setDisplayPortRect(1, 720, 0, 720, 810);

scripts.BittyCameraBlocks.setCameraSize(120, 135, 0);
scripts.BittyCameraBlocks.setCameraSize(120, 135, 1);

Interactive Viewport Setup Builder

Preview what the final layout will look like, then generate setup code for your project. Viewports split the game canvas, not the full screen.

Viewport Rects

Pixel Perfect Sizes

These are clean camera sizes based on your canvas size. 1x is the full canvas size.

    Generated Setup Code

    Generated Stencyl blocks
    
    
    Copy the blocks directly into your project.
    Initial camera and viewport setup
    
    

    Block Glossary

    This glossary is organized more like Stencyl’s block guide: blocks first, descriptions second, code shown directly under each block.

    Key Terms

    Display Area - The final rectangle where the whole bittyBIG output appears on the screen.

    Viewport - A rectangle inside the Display Area. It controls where a camera image appears.

    Camera Size - How much world the camera sees before zoom. This is your low-resolution world view size.

    Zoom - Changes how much of the world the camera sees. Higher zoom means a closer view.

    Viewport Coordinates - Based on the current Display Area size.

    Cameras

    Setup

    Initialize System

    Cameras → Setup
    Initialize bittyBIG Dynamic Camera System
    Initializes the bittyBIG dynamic camera, renderer, and display systems in the proper order for the current scene.
    Code
    scripts.BittyCameraSystem.init();

    Create Camera

    Cameras → Setup
    Create Camera ID
    Creates a new camera with the given camera ID.
    Code
    scripts.BittyCameraBlocks.createCamera(~);

    Render Camera to Viewport

    Cameras → Setup
    Render Camera ID to Viewport ID
    Draws the render image from the specified camera into the specified Viewport on the Game Image.
    Code
    scripts.BittyCameraBlocks.renderCameraToDisplayPort(~,~);

    Set Camera Size

    Cameras → Setup
    Set Camera to Width Height for Camera ID
    Sets the Camera size for the given camera ID.
    Code
    scripts.BittyViewports.setViewportSize(~, ~, ~);

    Set Camera Scene Lock

    Cameras → Setup
    Set Camera ID Scene Lock to Lock Camera To Scene
    Locks or unlocks the camera from being limited to the scene bounds.
    Code
    scripts.BittyCameraBlocks.setCameraSceneLock(~,~);

    Remove Camera

    Cameras → Setup
    Remove Camera ID
    Removes the camera with the given ID.
    Code
    scripts.BittyCameraBlocks.removeCamera(~);

    Presets

    Apply Camera Preset

    Cameras → Presets
    Apply Camera Preset Centered to Camera ID
    Applies one of the shipped camera presets to the selected camera.
    Code
    scripts.BittyCameraBlocks.applyCameraPreset(~,~);

    Apply Camera Preset by Name

    Cameras → Presets
    Apply Camera Preset named to Camera ID
    Applies any camera preset by name. Use this for custom presets added in BittyCameraPresets.hx.
    Code
    scripts.BittyCameraBlocks.applyCameraPreset(~,~);

    Position

    Set Camera Center

    Cameras → Position
    Set Camera Center to X Y for Camera ID
    Sets the camera center position for the given camera ID.
    Code
    scripts.BittyViewports.setCameraCenter(~, ~, ~);

    Set Camera Offsets

    Cameras → Position
    Set Camera Offset X Y for Camera ID
    Sets the horizontal and vertical offset used by camera follow movement.
    Code
    scripts.BittyCameraBlocks.setCameraOffsets(~,~,~);

    Center Camera to Actor

    Cameras → Position
    Set Camera Center to Actor for Camera ID
    Sets Camera Position to Center of Given actor. Removes Jitter from Stencyl's built-in Camera.
    Code
    scripts.BittyCameraBlocks.setCameraCenterToActor(~,~);

    Movement

    Set Camera Target Center

    Cameras → Movement
    Set Camera Target Center to X Y for Camera ID
    Sets the point this camera moves toward. Presets and follow settings control how the camera moves toward it.
    Code
    scripts.BittyCameraBlocks.setCameraTargetCenter(~,~,~);

    Set Camera Target to Actor

    Cameras → Movement
    Set Camera Target Center to Actor for Camera ID
    Sets the camera target center to the selected actor. Presets and follow settings control how the camera moves toward it.
    Code
    scripts.BittyCameraBlocks.setCameraTargetCenterToActor(~,~);

    Set Follow Style

    Cameras → Movement
    Set Follow Style to Direct for Camera ID
    Sets the camera follow style. Direct follows the target center directly. Grid-Based follows the center of the grid cell containing the target.
    Code
    scripts.BittyCameraBlocks.setCameraFollowStyle(~,~);

    Set Follow Speeds

    Cameras → Movement
    Set Follow Speed X Y for Camera ID
    Sets the horizontal and vertical follow speeds used by camera lerp movement.
    Code
    scripts.BittyCameraBlocks.setCameraFollowSpeeds(~,~,~);

    Set Lerp Speed

    Cameras → Movement
    Set Lerp Speed to for Camera ID
    Sets how heavily the camera movement is smoothed. Higher values move more slowly.
    Code
    scripts.BittyCameraBlocks.setCameraLerpSpeed(~,~);

    Set Zero Radius

    Cameras → Movement
    Set Zero Radius to for Camera ID
    Sets the snap distance used to finish camera movement cleanly near the target.
    Code
    scripts.BittyCameraBlocks.setCameraZeroRadius(~,~);

    Rotation

    Set Camera Rotation

    Cameras → Rotation
    Set Camera ID Rotation to Degrees
    Rotates the world view around the center of the given camera.
    Code
    scripts.BittyCameraBlocks.setCameraRotation(~,~);

    Get Camera Rotation

    Cameras → Rotation
    Get Camera ID Rotation
    Returns the current world-view rotation in degrees for the given camera.
    Code
    scripts.BittyCameraBlocks.getCameraRotation(~)

    Reset Camera Rotation

    Cameras → Rotation
    Reset Rotation for Camera ID
    Resets camera world-view rotation back to 0 degrees.
    Code
    scripts.BittyCameraBlocks.resetCameraRotation(~);

    Properties

    Camera Exists?

    Cameras → Properties
    Camera with ID exists
    Returns true if a camera with this ID is currently created.
    Code
    scripts.BittyViewports.cameraExists(~)

    Camera Is Transitioning?

    Cameras → Properties
    Camera ID is transitioning
    Returns true if the camera is still moving toward its target position.
    Code
    scripts.BittyCameraBlocks.isCameraTransitioning(~)

    Get Camera X

    Cameras → Properties
    Get Camera X for Camera ID
    Returns the camera X position for the given camera ID.
    Code
    scripts.BittyViewports.getCameraX(~)

    Get Camera Y

    Cameras → Properties
    Get Camera Y for Camera ID
    Returns the camera Y position for the given camera ID.
    Code
    scripts.BittyViewports.getCameraY(~)

    Get Camera Center X

    Cameras → Properties
    Get Camera Center X for Camera ID
    Returns the camera center X position for the given camera ID.
    Code
    scripts.BittyViewports.getCameraCenterX(~)

    Get Camera Center Y

    Cameras → Properties
    Get Camera Center Y for Camera ID
    Returns the camera center Y position for the given camera ID.
    Code
    scripts.BittyViewports.getCameraCenterY(~)

    Get Camera Width

    Cameras → Properties
    Get Camera Width for Camera ID
    Returns the Camera width for the given camera ID.
    Code
    scripts.BittyViewports.getViewportWidth(~)

    Get Camera Height

    Cameras → Properties
    Get Camera Height for Camera ID
    Returns the Camera height for the given camera ID.
    Code
    scripts.BittyViewports.getViewportHeight(~)

    Viewports

    Setup

    Create Viewport

    Viewports → Setup
    Create Viewport ID at X Y with Width and Height
    Creates a Viewport that defines where a camera image will be drawn on the Game Image.
    Code
    scripts.BittyCameraBlocks.createDisplayPort(~,~,~,~,~);

    Set Viewport Rect

    Viewports → Setup
    Set Viewport ID to X Y Width Height
    Sets the full rectangle of the given Viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortRect(~,~,~,~,~);

    Set Viewport Position

    Viewports → Setup
    Set Viewport ID Position to X Y
    Sets the position of the given Viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortPosition(~,~,~);

    Set Viewport Size

    Viewports → Setup
    Set Viewport ID Size to Width Height
    Sets the size of the given Viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortSize(~,~,~);

    Remove Viewport

    Viewports → Setup
    Remove Viewport ID
    Removes the Viewport entry for the given ID.
    Code
    scripts.BittyCameraBlocks.removeDisplayPort(~);

    Appearance

    Viewport Background Color

    Viewports → Appearance
    Set Viewport ID Background Color to Alpha percent
    Fills the given viewport before drawing the camera image.
    Code
    scripts.BittyCameraBlocks.setDisplayPortBackgroundColor(~,~,~);

    Clear Viewport Background

    Viewports → Appearance
    Clear Background for Viewport ID
    Disables the background fill for the given viewport.
    Code
    scripts.BittyCameraBlocks.clearDisplayPortBackground(~);

    Enable Viewport Background

    Viewports → Appearance
    Set Viewport ID Background to On
    Turns the viewport background fill on or off.
    Code
    scripts.BittyCameraBlocks.setDisplayPortBackgroundEnabled(~,~);

    Viewport Border

    Viewports → Appearance
    Add Border Thickness Color Alpha percent to Viewport ID
    Draws a colored border over the specified Viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortBorder(~,~,~,~);

    Viewport Scale Mode

    Viewports → Appearance
    Set Viewport ID Scale Mode to Pixel Perfect
    Sets how the viewport image is presented. Pixel Perfect keeps the current direct pixel-perfect rendering path. Scale to Fit uniformly scales the render image into the viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortScaleMode(~,~);

    Viewport Transforms

    Viewport Rotation

    Viewports → Viewport Transforms
    Set Viewport ID Rotation to Degrees
    Rotates the camera image inside the given viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortRotation(~,~);

    Flip Viewport Horizontally

    Viewports → Viewport Transforms
    Set Viewport ID Flip Horizontal to On
    Flips the camera image horizontally inside the given viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortFlipHorizontal(~,~);

    Flip Viewport Vertically

    Viewports → Viewport Transforms
    Set Viewport ID Flip Vertical to On
    Flips the camera image vertically inside the given viewport.
    Code
    scripts.BittyCameraBlocks.setDisplayPortFlipVertical(~,~);

    Reset Viewport Transform

    Viewports → Viewport Transforms
    Reset Transform for Viewport ID
    Resets viewport rotation and flipping back to normal.
    Code
    scripts.BittyCameraBlocks.resetDisplayPortTransform(~);

    Properties

    Viewport Exists?

    Viewports → Properties
    Viewport ID exists
    Returns true if a Viewport with this ID currently exists.
    Code
    scripts.BittyCameraBlocks.displayPortExists(~)

    Get Viewport X

    Viewports → Properties
    Get Viewport X for ID
    Returns the X position of the given Viewport.
    Code
    scripts.BittyCameraBlocks.getDisplayPortX(~)

    Get Viewport Y

    Viewports → Properties
    Get Viewport Y for ID
    Returns the Y position of the given Viewport.
    Code
    scripts.BittyCameraBlocks.getDisplayPortY(~)

    Get Viewport Width

    Viewports → Properties
    Get Viewport Width for ID
    Returns the width of the given Viewport.
    Code
    scripts.BittyCameraBlocks.getDisplayPortWidth(~)

    Get Viewport Height

    Viewports → Properties
    Get Viewport Height for ID
    Returns the height of the given Viewport.
    Code
    scripts.BittyCameraBlocks.getDisplayPortHeight(~)

    Display

    Setup

    Set Display Area

    Display → Setup
    Set Display Area to X Y Width Height
    Sets the full rectangle of the Display Area.
    Code
    scripts.BittyCameraBlocks.setGameAreaRect(~,~,~,~);

    Set Display Area Position

    Display → Setup
    Set Display Area Position to X Y
    Sets the position of the Display Area on the Canvas.
    Code
    scripts.BittyCameraBlocks.setGameAreaPosition(~,~);

    Set Display Area Size

    Display → Setup
    Set Display Area Size to Width Height
    Sets the size of the Display Area on the Canvas.
    Code
    scripts.BittyCameraBlocks.setGameAreaSize(~,~);

    Background

    Set Background Color

    Display → Background
    Set Background Color to Alpha percent
    Sets the background color using Stencyl's color picker plus alpha percent.
    Code
    scripts.BittyCameraBlocks.setBackgroundColorInt(~,~);

    Set Background Image

    Display → Background
    Set Background Image to
    Sets the Background Image used behind the final Game Image render.
    Code
    scripts.BittyCameraBlocks.setBackgroundImage(~);

    Clear Background Image

    Display → Background
    Clear Background Image
    Removes the current background image and uses background color only.
    Code
    scripts.BittyCameraBlocks.clearBackgroundImage();

    Has Background Image?

    Display → Background
    Has Background Image
    Returns true if a background image is currently assigned.
    Code
    scripts.BittyCameraBlocks.hasBackgroundImage()

    Properties

    Get Display Area X

    Display → Properties
    Get Display Area X
    Returns the X position of the Display Area.
    Code
    scripts.BittyCameraBlocks.getGameAreaX()

    Get Display Area Y

    Display → Properties
    Get Display Area Y
    Returns the Y position of the Display Area.
    Code
    scripts.BittyCameraBlocks.getGameAreaY()

    Get Display Area Width

    Display → Properties
    Get Display Area Width
    Returns the width of the Display Area.
    Code
    scripts.BittyCameraBlocks.getGameAreaWidth()

    Get Display Area Height

    Display → Properties
    Get Display Area Height
    Returns the height of the Display Area.
    Code
    scripts.BittyCameraBlocks.getGameAreaHeight()

    Effects

    Zoom

    Set Camera Base Size

    Effects → Zoom
    Set Base Size to Width Height for Camera ID
    Sets the base camera size used when calculating zoom. Zoom 1 uses this size.
    Code
    scripts.BittyCameraBlocks.setCameraBaseSize(~,~,~);

    Set Zoom

    Effects → Zoom
    Set Zoom to for Camera ID
    Sets the zoom for the given camera. 1 is normal, 2 is zoomed in 2x, and 0.5 is zoomed out 2x.
    Code
    scripts.BittyCameraBlocks.setCameraZoom(~,~);

    Tween Zoom

    Effects → Zoom
    Set Zoom to over seconds using Linear for Camera ID
    Smoothly changes the camera zoom using the selected easing mode.
    Code
    scripts.BittyCameraBlocks.setCameraZoomAdvanced(~,~,~,~);

    Get Camera Zoom

    Effects → Zoom
    Get Camera Zoom for Camera ID
    Returns the current zoom value for the given camera.
    Code
    scripts.BittyCameraBlocks.getCameraZoom(~)

    Reset Camera Zoom

    Effects → Zoom
    Reset Camera Zoom for Camera ID
    Resets the camera zoom back to 1.
    Code
    scripts.BittyCameraBlocks.resetCameraZoom(~);

    Screenshake

    Shake Camera

    Effects → Screenshake
    Shake Camera ID with Strength for seconds
    Shakes the camera view for the given camera ID.
    Code
    scripts.BittyCameraBlocks.shakeCamera(~,~,~);

    Shake Camera XY

    Effects → Screenshake
    Shake Camera ID with Strength X Y for seconds
    Shakes the camera view with separate horizontal and vertical strengths.
    Code
    scripts.BittyCameraBlocks.shakeCameraXY(~,~,~,~);

    Stop Camera Shake

    Effects → Screenshake
    Stop Shaking Camera ID
    Stops any active screen shake for the given camera ID.
    Code
    scripts.BittyCameraBlocks.stopCameraShake(~);

    Troubleshooting / FAQ

    These are the common first-time problems and quick fixes. Start here when something looks wrong before digging into the deep technical cave. The cave has bats. Probably Haxe bats.

    Problem: Nothing appears, or the camera system acts like it does not exist.

    Initialize bittyBIG Dynamic Camera System

    Solution: Begin every scene with this block before using any camera, viewport, display, zoom, rotation, or screenshake blocks.

    Problem: A camera was created, but it is not showing in the right place.

    Render Camera ID to Viewport ID

    Solution: Make sure the camera is rendered to a viewport. Use this block after creating the camera and viewport.

    Problem: The viewport is too large, too small, or off-screen.

    Solution: Use Display Area units. If the Display Area is 960x540, a left-half viewport is 0, 0, 480, 540. Use the Viewport Tester for help.

    Problem: The camera shows too much or too little of the world.

    Solution: Change Camera Size, not Viewport Size. Camera Size controls how much world the camera sees before zoom.

    Problem: Split-screen math feels wrong.

    Solution: Split the Display Area, not the screen. For a 720x405 Display Area, left/right split uses 360x405 for each viewport.

    Problem: Pixel art looks uneven or blurry.

    Solution: Use camera sizes that scale evenly into the viewport. Example: 320x180 into 1920x1080 gives a clean 6x scale.

    Problem: Zoom looks broken or crops more than expected.

    Solution: Remember that zoom changes how much world the camera sees. Higher zoom means closer view. Set the camera base size first, then apply zoom.

    Problem: The camera follows the wrong actor or crashes when centering.

    Solution: Make sure the actor variable exists before using it in the block. In the Quick Start example, player means your own actor variable.

    Problem: A viewport background or border does not appear.

    Solution: Check that the viewport exists first and that alpha is above 0. For a fully visible color, use 100 percent alpha.

    Problem: The display area is smaller than the screen and there is empty space around it.

    Solution: That can be correct. The Display Area is where the camera output appears. Use background color or background image blocks to control what appears behind it.

    Release Notes v 1.0

    This release focuses on camera, viewport, display, zoom, rotation, screenshake, multi-viewport support, and pixel-perfect behavior.

    Planned Development:

    • Add cached tile/world rendering so bittyBIG can rely less on Stencyl’s live redraw path.
    • Show debug drawing per viewport.