Batzi Posted November 2, 2015 Share Posted November 2, 2015 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 thinkvar 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/ MichaelD, WombatTurkey and nocaoper 3 Link to comment Share on other sites More sharing options...
Get_Bentley Posted November 2, 2015 Share Posted November 2, 2015 Looks good man! Definitely gave me a better understanding on how the loading bar works. Thanks. Batzi 1 Link to comment Share on other sites More sharing options...
Batzi Posted November 2, 2015 Author Share Posted November 2, 2015 Looks good man! Definitely gave me a better understanding on how the loading bar works. Thanks.You're welcome! Link to comment Share on other sites More sharing options...
ekeimaja Posted November 2, 2015 Share Posted November 2, 2015 This is simpliest sample I've seen by now. Good work! Batzi 1 Link to comment Share on other sites More sharing options...
Batzi Posted November 2, 2015 Author Share Posted November 2, 2015 This is simpliest sample I've seen by now. Good work! Thank you! I'm glad I could help Link to comment Share on other sites More sharing options...
WombatTurkey Posted November 3, 2015 Share Posted November 3, 2015 Great little snippet, good work Batzi Link to comment Share on other sites More sharing options...
in mono Posted November 3, 2015 Share Posted November 3, 2015 This is indeed maybe the simplest solution, but unfortunately it won't work for sprites that can't directly be scaled along x. Link to comment Share on other sites More sharing options...
Skeptron Posted November 3, 2015 Share Posted November 3, 2015 I don't get why people would struggle with load bars when all you need to do it just pass a sprite to the loader : http://phaser.io/docs/2.3.0/Phaser.Loader.html The loader will crop the bar accordingly, regarding the % of downloaded assets. Basically you don't have anything to code. ? drhayes 1 Link to comment Share on other sites More sharing options...
Batzi Posted November 3, 2015 Author Share Posted November 3, 2015 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 BatziThank you! in mono 1 Link to comment Share on other sites More sharing options...
Recommended Posts