Skip to content

Drawables

Adrian K edited this page May 6, 2026 · 1 revision

Drawables are all graphic related platforms, lever, conveyors and sands created by creating an xml document.
Unlike vanilla props these are aware of states and can change their render appropriately.
It is not needed to use drawables should you not require them or determine that you have no use for how they work. If there is no desire to use the left/right halves of the lever drawable they can be ignored and the lever may be indicated by other means like the level texture or a prop.


They are defined inside various xml files named levers<SCREEN NR>.xml, platforms<SCREEN NR>.xml, conveyors<SCREEN NR>.xml, and sands<SCREEN NR>.xml replacing the <SCREEN NR> with the screen you want the drawable to appear on.
E.g. platforms3.xml to create platforms that appear on screen 3.
These files are then placed inside the folder of the block type you want to create drawables for.
E.g. <YOUR MAP>\switchBlocksMod\basic\platforms3.xml to create platforms for the basic block type.

When starting the game in debug mode switch blocks provide a pause menu item that lets you generate templates for the different drawables automatically, assuming it can find the Worldsmith folder structure.
This means the map is started using the compiled files inside the bin folder, compiled from files outside the bin folder, one folder level up.
The templates will be placed inside the templates folder.
Templates contain two examples, one of the required minimum to create a drawable and a second one that contains all possible elements.

Not all drawables can be created for all types, lever-less block types like auto cannot have levers, sand-less block types like group or sequence cannot have sands.

Position

The position is the screen coordinates position the drawable should be placed at.
It is not required to place the drawable at the same position as any blocks in the map, you may choose screen and position freely.

Textures

Textures for drawables are placed inside the folder <YOUR MAP>\switchBlocksMod\textures and depending on the drawable are of different formats.

Levers

Textures for levers are separated into a left and right half. Which half is shown is determined by the state of block type, the left half when the state is off and the right when the state is on.

Platforms

Textures for platforms have no special state dependant rendering.

Conveyors

Conveyors require at least one background OR foreground texture. This is required to determine the size of the scroll.
Like levers the back-/foreground texture is separated in a left and right half that will render based on state.
The scroll texture should be at least as wide as the back-/foreground half. When scrolled the left and right sides will appear next to each other and should be made to appear seamless.

Sands

Sands require at least one background OR foreground texture. This is required to determine the size of the scroll.
Like levers the back-/foreground texture is separated in a left and right half that will render based on state.
The scroll texture should be at least as tall as the back-/foreground. When scrolled the top and bottom sides will appear next to each other and should be made to appear seamless.

StartState

The start state element supports the values on, off, and always.
As block types start in the off state the chosen start state should be on, this feels backwards and I am sorry for making it this way.
always will make the drawable ignore state and render at all times.
The default start state is off.

IsForeground / IsBackground

The normal render order of drawables places them right in front of the player (they render before the player is rendered placing them behind behind the player visually). This can be influenced by these elements moving them into the background or foreground as required.
The render order as such is: IsBackground drawables > Others up to player > Neither background nor foreground drawables > Player > Others after player > IsForeground drawables.
The actual order of other non-player drawables may be influenced by the mod load order.
The default for both is false.

Animation

Platforms support an animation when changing state.
An animation is made up of two elements, these being a style and a curve. The style being how the drawable transitions between states in regards to looks, the curve being how the drawable transitions between states in regard to its speed (the animation will take the same time to complete, except in the case of Stepped).
Style options are Fade, Top, Bottom, Left, and Right. The default is Fade.
Curve options are Linear, EaseIn, EaseOut, EaseInOut, and Stepped. The default is Linear.
The default for AnimationOut are the values chosen in Animation.

Sprites

Not to be confused with animations, which is exclusively referring to the way a drawable changes state.
The sprites element allows for the platforms itself to be animated using a sprite sheet approach.

Cells

Specifies how many cells the texture contains per row and column. The default value for X and Y is 2.

Fps / Frames

Specifies at how many FPS the animation is played. For finer control define a Frames element listing the durations a cell should be active for in a list of float elements. The Frames element has precedence over the FPS tag.
The setting supports decimal numbers.
The default value for FPS is 1.

RandomOffset

The animation may start at a random point inside the animation timeframe.
The default value is false.

ResetWithLever

The animation should restart at the beginning when a lever is touched.
The default value is false.

IgnoreState

The animation will pause when the drawable is not active, to not pause the animation set this value.
The default value is false.

Multiplier

This setting controls the speed at which the scroll plays for drawables that posses a scrolling functionality.
Only the sand block type is influenced by the Multiplier value set in settings as well as this element. All other block types do not have their speed influenced by the multiplier setting.
The setting supports decimal numbers.
The default value is 1.

Templates

Levers

<?xml version="1.0" encoding="utf-8"?>
<Levers>
  <!-- This is the minimum you need to create a lever -->
  <Lever>
    <Texture>TEXTURE NAME HERE</Texture>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
  </Lever>
  <!-- These are all possible options -->
  <Lever>
    <Texture>TEXTURE NAME HERE</Texture>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
    <!-- Setting IsForeground will override IsBackground -->
    <IsForeground />
    <IsBackground />
  </Lever>
</Levers>

Platforms

<?xml version="1.0" encoding="utf-8"?>
<Platforms>
  <!-- This is the minimum you need to create a platform -->
  <Platform>
    <Texture>TEXTURE NAME HERE</Texture>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
  </Platform>
  <!-- These are all possible options -->
  <Platform>
    <Texture>TEXTURE NAME HERE</Texture>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
    <!-- Setting IsForeground will override IsBackground -->
    <IsForeground />
    <IsBackground />
    <!-- Start states are: On, Off, Always -->
    <StartState>On</StartState>
    <Animation>
      <!-- Styles are: Fade, Top, Bottom, Left, Right -->
      <Style>Fade</Style>
      <!-- Curves are: Linear, EaseIn, EaseOut, EaseInOut, Stepped -->
      <Curve>Linear</Curve>
    </Animation>
    <AnimationOut>
      <!-- Styles are: Fade, Top, Bottom, Left, Right -->
      <Style>Fade</Style>
      <!-- Curves are: Linear, EaseIn, EaseOut, EaseInOut, Stepped -->
      <Curve>Linear</Curve>
    </AnimationOut>
    <Sprites>
      <Cells>
        <X>2</X>
        <Y>2</Y>
      </Cells>
      <!-- The Frames element overrides the FPS if defined -->
      <FPS>3</FPS>
      <Frames>
        <float>1.2</float>
        <float>0.3</float>
        <float>0.3</float>
      </Frames>
      <RandomOffset />
      <ResetWithLever />
      <IgnoreState />
    </Sprites>
  </Platform>
</Platforms>

Conveyors

<?xml version="1.0" encoding="utf-8"?>
<Conveyors>
  <!-- This is the minimum you need to create a scrolling platform -->
  <Conveyor>
    <!-- Background OR Foreground is required, the minimum is ONE of the two -->
    <Background>TEXTURE NAME HERE</Background>
    <Foreground>TEXTURE NAME HERE</Foreground>
    <Scrolling>TEXTURE NAME HERE</Scrolling>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
  </Conveyor>
  <!-- These are all possible options -->
  <Conveyor>
    <Background>TEXTURE NAME HERE</Background>
    <Scrolling>TEXTURE NAME HERE</Scrolling>
    <Foreground>TEXTURE NAME HERE</Foreground>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
    <!-- Setting IsForeground will override IsBackground -->
    <IsForeground />
    <IsBackground />
    <!-- Start states are: On, Off, Always -->
    <StartState>On</StartState>
    <Multiplier>2.5</Multiplier>
  </Conveyor>
</Conveyors>

Sands

<?xml version="1.0" encoding="utf-8"?>
<Sands>
  <!-- This is the minimum you need to create a scrolling platform -->
  <Sand>
    <!-- Background OR Foreground is required, the minimum is ONE of the two -->
    <Background>TEXTURE NAME HERE</Background>
    <Foreground>TEXTURE NAME HERE</Foreground>
    <Scrolling>TEXTURE NAME HERE</Scrolling>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
  </Sand>
  <!-- These are all possible options -->
  <Sand>
    <Background>TEXTURE NAME HERE</Background>
    <Scrolling>TEXTURE NAME HERE</Scrolling>
    <Foreground>TEXTURE NAME HERE</Foreground>
    <Position>
      <X>100</X>
      <Y>50</Y>
    </Position>
    <!-- Setting IsForeground will override IsBackground -->
    <IsForeground />
    <IsBackground />
    <!-- Start states are: On, Off, Always -->
    <StartState>On</StartState>
    <Multiplier>2.5</Multiplier>
  </Sand>
</Sands>

Clone this wiki locally