00:00
00:00
Newgrounds Background Image Theme

MovementalStudio just joined the crew!

We need you on the team, too.

Support Newgrounds and get tons of perks for just $2.99!

Create a Free Account and then..

Become a Supporter!

Tutorials on data-saving/shops?

430 Views | 5 Replies
New Topic Respond to this Topic

Tutorials on data-saving/shops? 2014-06-30 16:06:31


Hi, I've tried googling some resources on how to build a shop/inventory system but can't really find anything useful.

I'm trying to build a in-game shop that has a upgrade/weapon store, that can uses in game currency "coin-count" to save how much $$$ you have.

Are there any resources that you NG'rs know of that might help me build a shop/store thingy that saves your data when you quit the game and return back to it.

Thanks!

Response to Tutorials on data-saving/shops? 2014-06-30 20:56:18


At 6/30/14 04:06 PM, Joyhype wrote: Hi, I've tried googling some resources on how to build a shop/inventory system but can't really find anything useful.

I'm trying to build a in-game shop that has a upgrade/weapon store, that can uses in game currency "coin-count" to save how much $$$ you have.

Are there any resources that you NG'rs know of that might help me build a shop/store thingy that saves your data when you quit the game and return back to it.

Thanks!

are you trying to have persistent data between different levels/states of the game or persistent data from the last time they closed the game?

Response to Tutorials on data-saving/shops? 2014-07-01 13:08:51


At 6/30/14 08:56 PM, GeoKureli wrote:
At 6/30/14 04:06 PM, Joyhype wrote: Hi, I've tried googling some resources on how to build a shop/inventory system but can't really find anything useful.

I'm trying to build a in-game shop that has a upgrade/weapon store, that can uses in game currency "coin-count" to save how much $$$ you have.

Are there any resources that you NG'rs know of that might help me build a shop/store thingy that saves your data when you quit the game and return back to it.

Thanks!
are you trying to have persistent data between different levels/states of the game or persistent data from the last time they closed the game?

I'm trying to make it so it's like "Jetpack joyride" you collect coins from killing bad guys and it gets saved into a "bank" in the game that you can use it to spend money on, but if you quit the game I don't want it so that you start back at 0 coins but rather x amount of coins you collected last time.

Response to Tutorials on data-saving/shops? 2014-07-01 13:55:50


At 7/1/14 01:08 PM, Joyhype wrote: I'm trying to make it so it's like "Jetpack joyride" you collect coins from killing bad guys and it gets saved into a "bank" in the game that you can use it to spend money on, but if you quit the game I don't want it so that you start back at 0 coins but rather x amount of coins you collected last time.

You can use Shared Objects aka "Flash Cookies" to store data. The 2nd link has the explanation for how to use them, just be sure not to save your data too often because it will lag a bit. Saving at the end of a level or at checkpoints is best.

Response to Tutorials on data-saving/shops? 2014-07-01 13:58:39


At 7/1/14 01:08 PM, Joyhype wrote: I'm trying to make it so it's like "Jetpack joyride" you collect coins from killing bad guys and it gets saved into a "bank" in the game that you can use it to spend money on, but if you quit the game I don't want it so that you start back at 0 coins but rather x amount of coins you collected last time.

To store data after they close the game you would use a SharedObject. A SharedObject is a piece of data that persists after close. you simply say:

var saveFile:SharedObject = SharedObject.getLocal("game name");

To retrieve previous data, and then to save data it's just:

saveFile.data.coins = 10;
saveFile.flush();

just know that some people have their flash player set up so that it can't store data, if you call flush it will crash on them, you'll have to use a try...catch

try {
	saveFile.flush
 } catch (e:Error) {
	trace("Player cannot save data");
}

Response to Tutorials on data-saving/shops? 2014-07-01 14:01:11


forgot to mention that if you use shared objects, then the data will not work if they play on different computers, web pages, or browsers. To keep data across these differences you need a server and some kind of log in.

Newgrounds offers this for free, just create a project in the nifty project manager, select your project and go to API Tools > Save Data, and use theirs.