jw405 Posted January 7, 2016 Share Posted January 7, 2016 Hi all, I have a collection of five bee spritesheets and I have assigned them unique strings such as, 'bee1', 'bee2' etc. I randomly generate a character/bee at the start of each game by: // Randomly generate an integer and identify unique string var randomBee = 'bee'+ this.game.rnd.integerInRange(1,5); // Add sprite this.bee = this.game.add.sprite(100, 245, randomBee); HOWEVER, I wanted to display the characters name (top right): var beeName = getName(randomBeeKey); AND function getName(beeKey) { if(beeKey === "bee1") return "Boobee"; if(beeKey === "bee2") return "Digbee"; if(beeKey === "bee3") return "Feebee"; if(beeKey === "bee4") return "Abbee"; if(beeKey === "bee5") return "Newbee"; } I can't seem to get it working, any help would be appreciated! Here's my code if I'm not making sense: http://pastebin.com/dGpW5ezw Quote Link to comment Share on other sites More sharing options...
AzraelTycka Posted January 7, 2016 Share Posted January 7, 2016 Hello, randomBeeKey is not declared, but randomBee is, so perhaps change that? Quote Link to comment Share on other sites More sharing options...
Recommended Posts
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.