Jump to content

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 = game.add.graphics(200,300);    barGreen.beginFill(0xEAF516);    barGreen.drawRect(0,0,300,50);    barYellow = game.add.graphics(200,300);    barYellow.beginFill(0x4BFAF7);    barYellow.drawRect(0,0,300,50);        maxWidth = 300;    barYellow.width=0;        tween = game.add.tween(barYellow);    tween.to({width:maxWidth},1000);    tween.start();}

Here's the JSFiddle if you want to see what it looks like: http://jsfiddle.net/Batzi/op3grg2w/10/

Link to comment
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! :)

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Recently Browsing   0 members

    • No registered users viewing this page.
  • Create New...