SHOW:
|
|
- or go back to the newest paste.
1 | /* | |
2 | - | Basically your leveldata(yourData) is an array with all the info of the tiles(or player, etc.) that |
2 | + | Basically your leveldata(yourData) is an array with all the info of the tiles(or player, etc.) |
3 | - | are in the level for example: a block data could hold x and y coordinate, like [3, 7], this is stored |
3 | + | that are in the level for example: a block data could hold x and y coordinate, like [3, 7], |
4 | - | in one big array, or a 2D array, which represents the level. |
4 | + | this is stored in one big array, or a 2D array, which represents the level. |
5 | */ | |
6 | ||
7 | // In MyEditorManager | |
8 | override public function blEditLvl(data:ByteArray):void { | |
9 | data.position = 0; // to prevent end of file errors | |
10 | - | if(data.length == 0) yourData = emptyLevel(); // if it can't find a level to edit, it will create an empty level |
10 | + | if(data.length == 0) yourData = emptyLevel(); |
11 | // if it can't find a level to edit, it will create an empty level | |
12 | - | sendEditResult(true, ""); // to send to bl that it is ready to edit the level |
12 | + | |
13 | sendEditResult(true, ""); // to send to bl that the editor is ready to edit the level | |
14 | } | |
15 | ||
16 | override public function blGetLvlData():void { | |
17 | var byte:ByteArray = new ByteArray(); | |
18 | byte.writeObject(yourData); // storing your leveldata into a byteArray | |
19 | sendLvlData(true, byte); // sends the bytearrayy to bl | |
20 | } | |
21 | ||
22 | ||
23 | // In MyGameManager | |
24 | override public function blPlayLvl(data:ByteArray, official:Number):void { | |
25 | yourData = data.readObject(); // reads your to be played leveldata | |
26 | } | |
27 | ||
28 | /* | |
29 | After you've done this, you still have to make your level with the 'data', for example you could use | |
30 | [3, 7] to place a block at coordinate (3, 7) | |
31 | This is the same for the editor, you'll have to place the blocks in the editor, but it's basically | |
32 | just reading yourData. I hope this was clear enough, if you've any questions, please ask them. | |
33 | */ |