Sprite Renderer

Updated On: April 8, 2013

A Sprite Renderer is a component used to render simple sprites / textures to screen. You will notice a mini preview area that displays the sprite rendered by this component.


Selecting An Asset


After you import an asset into GBS via the Assets tab it will appear hear in the dropdown. The registration point of any renderer is indipendent of the position. It defines the center point or pivot point of an image. You will notice after changing the registration point that the center of rotation changes if you change the rotation property.

Renderer Properties


All renderers in GameBuilder Studio can have a controlling spatial. You can elect to not attach a controlling renderer and manually change the position of the renderer. If you want to have an image of a ball bounce with physics you would a physics spatial to the same entity and select it here as the controlling spatial.

  • Position - controls the X and Y cordinates in space that this renderer should appear.
  • Position Offset - is an additional value that is added to position to offset the renderer. This offset is applied after rotation so it may appear like the rotation is messed up. If you have two renderers controlled by the same spatial and want an offset that looks right after rotation try changing the registration point instead.
  • Size - the width and height of the renderer
  • Scale - is a multiplier that will scale up an image. You will notice pixelation if your are upsizing an image bigger than its original size.
  • Blend Mode - applies a blend mode to the renderer.
  • Alpha - controls the opacity of the renderer. 0 is hidden and 1 is fully visible.
  • Render Order - this is a secondary sort that is used for entities with multiple renderers on the same layer. 0 is the bottom of the render order.
  • Snap To Nearest Pixel - this will round all position and size numbers to the nearst integer or whole number.

Blend Mode Examples


Code Sample

var entity : IEntity = PBE.allocateEntity();

var spriteRenderer : SpriteRenderer = new SpriteRenderer();
spriteRenderer.fileName = "assets/image.png";
var bitmapImageData : BitmapData = new BitmapData(200, 200);
bitmapImageData.draw( displayObject );
spriteRenderer.bitmapData = bitmapImageData;

//Add the renderer to a scene to display it
spriteRenderer.scene = scene; 

entity.addComponent(spriteRenderer, "SpriteRenderer");

Follow Us For Updates