b2dCreateSubImage

Category: 2D Overlay

Syntax:

b2dCreateSubImage:Int(imageHandle:Int, x:Int, y:Int, width:Int, height:Int)


Parameters

Returns

Int



Summary

Makes an image from a rectangle of another image (a sprite sheet), sharing its texture.

View detailed documentation online



Example
Global sheet:Int = b2dLoadImage("Media/sprites.png")

; cut sprites out of the sheet - any size, anywhere
Global player:Int = b2dCreateSubImage(sheet, 0, 0, 32, 48)
Global coin:Int = b2dCreateSubImage(sheet, 32, 0, 16, 16)

b2dSetImageMidHandle(player)
b2dDrawImage(player, 400, 300)
b2dDrawImage(coin, 100, 100)

BambooBasic © 2026 Michael Denathorn