如何让我的 Flash AS3 游戏保存进度 [英] how to I make my flash AS3 game save progress

查看:39
本文介绍了如何让我的 Flash AS3 游戏保存进度的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个我一直在开发的 Flash 游戏,它可以在浏览器之外运行,我希望得到它以保存它的进度.

I have this flash game that I've been working on that works out of the browser, and I'm looking to get it to save it's progress.

我已经看到多个 Flash 游戏已经实现了这一点,而且看起来好像他们已经完成了这个客户端,我也想这样做.

I've seen multiple flash games that have accomplished this, and It appears as though they've done this client-side, and I'd like to do the same.

我的游戏由 1 个 mxml 文件和多个 .as 文件组成,我使用 flex sdk 从命令行编译它.

My game consists of 1 mxml file and a number of .as files and I compile it from the command line using flex sdk.

我需要做什么才能保存我的游戏数据?

What do I have to do to be able to save save my game's data?

推荐答案

正如其他人提到的,SharedObject 是您将使用的工具.

As others have mentioned, SharedObject is the tool you'll use for this.

其基础是首先使用其静态方法 .getLocal() 初始化对 SharedObject 的引用:

The basics of this are to initialize a reference to a SharedObject using its static method .getLocal() first:

var mySaveData:SharedObject = SharedObject.getLocal("SomeSaveName");

赋予此方法的字符串不应包含空格.

The String given to this method should not contain spaces.

完成此操作后,您将能够使用 mySaveData.data,它基本上是一个简单的对象,您可以动态附加属性(它是动态的):

Once you've done this, you'll be able to use mySaveData.data, which is basically a simple object that you can attach properties to on the fly (it's dynamic):

mySaveData.data.levelsComplete = 2;

完成此操作后,您将能够在以后使用相同的过程引用该值:

Once you've done this, you'll be able to reference that value later on using the same process:

trace( mySaveData.data.levelsComplete );

这篇关于如何让我的 Flash AS3 游戏保存进度的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆