Jump to content

My loading bar/progress bar solution


Batzi
 Share

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

 Share

  • Recently Browsing   0 members

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