My loading bar/progress bar solution

Recommended Posts

So I noticed that a lot of people in here were asking about a loading/progress bar so I came up with my own solution.


Let me know what you think

var barGreen,barYellow,maxWidth,tween;function create(){    barGreen =,300);    barGreen.beginFill(0xEAF516);    barGreen.drawRect(0,0,300,50);    barYellow =,300);    barYellow.beginFill(0x4BFAF7);    barYellow.drawRect(0,0,300,50);        maxWidth = 300;    barYellow.width=0;        tween = game.add.tween(barYellow);{width:maxWidth},1000);    tween.start();}

Here's the JSFiddle if you want to see what it looks like:

Share this post

Link to post
Share on other sites

This is indeed maybe the simplest solution, but unfortunately it won't work for sprites that can't directly be scaled along x.

Well this is taking into account that no sprites are involved. The point of my code is to completely remove the need to use a sprite to crop. I needed it to do a progress bar for the game I am working on.



Great little snippet, good work Batzi

Thank you! :)

Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

  • Recently Browsing   0 members

    No registered users viewing this page.