2D Framework | Make 2D Games in Roblox

2D Framework

Introduction
This is a Framework in Progress to make fully 2D, GUIObject based Games on Roblox easy.
But aren’t there 2D Games on Roblox already? Yes and no. The current 2D Games are all based around the Idea of having a 3D Space look 2D by essentially getting rid of anything on the Z axis. While this is a good and efficient approach, the 3rd Dimension still exists and can still be seen. The only real way of making a proper 2D Game in Roblox at this time is to use GUIs, which are limited to 2 Dimensions.

How to use it
It is fairly easy to use assuming you have some scripting knowledge and know how to use modules. I plan on making a Plugin for it which adds a moveable Camera outside of Run Mode, kind of like the actual Studio Camera but in 2D, together with some tools that help you place Frames etc.

Features
As of now (06.02.2021), the Framework includes:

  • Rigidbody Class
  • CharacterController Class
  • BoxCollider Class
  • ParticleEmitter Class
  • SpriteSheet Class
  • Weld Class

Most of the Classes come with alot of different Customizable Settings which I wont go in depth about yet because it isnt released yet.

Examples


You can try it out yourself here: https://www.roblox.com/games/6265545430/2D-Framwork-Test

Code for the above game for those who are interested
local character = script.Parent.Cube;
local passive, active = script.Parent.Passive, script.Parent.Active;
local UIF = game.ReplicatedStorage.UIFramework;
UIF = require(UIF);
UIF.UnbindWalk(); -- optional if u want to disable ur actual character in workspace walking
UIF.DisableCore(); -- optional if u want to disable core GUIs

local charactercollider = UIF.NewInstance("BoxCollider",character); -- add boxcollider to character
local characterrigid = UIF.NewInstance("Rigidbody",character); -- add rigidbody to character
local charactercontroller = characterrigid:AddController(); -- optional if you dont want to make a custom character controller

local characteranimations = {};
characteranimations.walk = UIF.NewInstance("SpriteSheet",character); -- create new spritesheet for walking

characteranimations.walk.Looped = true;
characteranimations.walk:Add(6332856820,6332856726,6332856639,6332856532); -- ImageIds
charactercontroller.AutoRotate = true;

charactercontroller:SetAnimation(UIF.AnimationType.Walk,characteranimations.walk);
charactercontroller:SetSound(UIF.SoundType.Jump,5024697269); -- SoundId

for i,v in pairs(passive:GetChildren()) do -- loop through passive objects and add collider
	UIF.NewInstance("BoxCollider",v);
end;
for i,v in pairs(active:GetChildren()) do -- loop through active objects and add collider and rigidbody
	UIF.NewInstance("BoxCollider",v);
	UIF.NewInstance("Rigidbody",v);
end;

game:GetService("RunService").RenderStepped:connect(function() -- main loop
	UIF.MoveCameraByPosition(script.Parent,Vector2.new(character.AbsolutePosition.X,0),15);
	UIF.Update();
end);
-- extra stuff
local d = false;
game.Players.LocalPlayer:GetMouse().Button1Down:Connect(function() -- invert gravity on click
	d = not d;
	UIF.SetGravity(d and -10 or 10);
	charactercontroller.JumpPower = (d and -20 or 20);
	game:GetService("SoundService").Gravity:Play();
	charactercontroller:UpdateDirection(); -- set characters rect size incase it hasnt updated yet
end);

local particle = script.Parent.ParticleEmitter;
local emitter = UIF.NewInstance("ParticleEmitter",particle); -- creates emitter with default settings
emitter.CanCollide = true;
emitter.IgnoreList = {character}; -- to avoid the character from jumping ontop of particles

local star = script.Parent.Star;
local starcollider = UIF.NewInstance("BoxCollider",star); -- add boxcollider
starcollider.CanCollide = false; --  no collisions, but touched event still works
local debounce = false;
starcollider.Touched:Connect(function() -- simple function when the Star is touched
	if (not debounce and starcollider:IsTouching(character)) then
		game:GetService("SoundService").Coin:Play();
		debounce = true;
		star.Visible = false;
		wait(1)
		star.Visible = true;
		debounce = false;
	end;
end);

local spritesheet = UIF.NewInstance("SpriteSheet",star); -- star animation
spritesheet:Add(6332041014,6332536736);
spritesheet.Reverse = true;
spritesheet.Looped = true;
spritesheet.WaitTime = 0.05;
spritesheet:Play();

Release Information
I plan on making this free to use and Open Source, although it might take some time to get it ready to be used in an actual Game. There is no date on when this could be because I am making this as a side Project.

End Note
There are some known Bugs like Rigidbodies teleporting ontop of Particles when the Gravity changes, or Welded Rigidbodies being unpushable in one Direction. While they are quite annoying, My main Priority is to release this to the public before fixing small bugs.

I would appreciate any Feedback and thank you for reading this.

32 Likes

Truly amazing! I made an arcade recently and thought on making a PacMan, this could work! Great work!

(If you want to make it yourself here’s the model.

2 Likes

This is amazing. I like the idea for the expansion of 2D games on roblox. I like the gravity change, where it goes upside down, reminds me of terraria. Good job!

2 Likes

Thank you! I will definitely take a look.

1 Like

(Sorry for bumping the Topic)

This is a very under-rated project! Is there any updates coming soon? How does it work??

1 Like

hi, will you make the game open-source at the end? thank you ^^

1 Like

Hi. I would really appreciate it if this would be open source soon. Your work is amazing.

1 Like