|
|
|||||
Topic, Path 4 Mouse Help | ||||||
| ||||||
You must register or log in to post a message.Maybe you should host your fla's and version of the api you're using online somewhere. I know I don't have flash 8 so I couldn't look at it and test it for you, but jp might be able to help. Although that's really up to him... Have a look at the game and see for yourself, you can type in the text box, you can capture a thumbnail, but you can't save, upload or test the level... In response to you code question. The unserializeAndPlay function will only be called once the level is loaded. Your code that displays the level is on the first (ok, actually second) frame of your game, meaning that it will run once the game loads, not once the level loads. You can run this code once the level loads by putting it inside of a function and calling that function from within the unserializeAndPlay function - I downloaded the package here http://www.bonuslevel.org/about/f8.rar - I unrared the package. - I compiled editor_example1.fla - I uploaded editor_example1.swf on my game. When I click on the UPLOAD button, it works and save a level. Can you try to do exaclty the same ? In case you copied some of the files from the apckage to your own dir, aybe you forgot to copy some of the files ? check that you didn't forget Serializer.as MyLevelData.as (of coure MyEditorManager.as and EditorManager.as also). So while I'm waiting, can someone help me with the code on the second frame? I know it's not quite right, but I don't know what is wrong with it... I want the current level to load up and get made into a map. I think the main problem is with this part: function unserializeAndPlay(data:String) { leveldata.unserialize(data); map = levelToArray(data); return true; } Check below to see the rest of the code. Further, I think it may just be an incompatibility with the version of flash you're using, I had similar problems not too long ago. If I were you, I'd sit tight and wait for jp to do his magic coding thing. On the second frame, I have this code: (I know the code in the second frame is wrong, but shouldn't BL still apply the basic functionality of the save, upload, and test buttons in the editor???) Is there anything wrong with the code on the first frame, or something I need to add? As long as the API was declared inside the game properly (and was the right version, etc), it would still work. I will check this problem this evening. And no, I didn't save a backup... Maybe I could just press Ctrl + Z... [edit] Ok, I've fixed that problem, but the buttons still don't do much... I'll carry on working on the game engine, but I don't know if it will work or not... Did you at least keep a backup of the other version? If not, remember to do that next time, you always need something to fall back on. Did you download the API file or the example file? I'll download the MyGameManager and MyEditorManager codes again though, just to be sure... Argh!! Now the buttons have disappeared again! Do you think this is a problem with the editor, the player, or one of the My?Manager files? I'm trying to do what THeNiNJa did for his editor (use the BL demo editor), but the options for thumbnails, testing, saving and uploading don't appear at the bottom, there is just a blank screen with a text box... What am I doing wrong? [edit] Actually, I just deleted a load of things with 'override' before them in MyEditorManager, and now it works perfectly... [edit2] Ok, but when I press test, save or upload, nothing happens... public function blInit() { _root.init(); } This will be called only once. There is antoher method blWelcome() that is called each time you click on STOP when playing a game. you can implement or not this method. Like this for example. public function blWelcome() { _root.gotoWelcomeScreen(); } Wouldn't you just have to add a line of code inside BLInit telling your intro to play? I haven't used the function all that much though, so I really don't know. Although, if I were you, I'd just focus on getting the editor and game engine working properly before you do anything else. So how should I use blinit? I want my introduction to play only when everything has finished loading. If you realize later that you need to had something in your level that is not possible with your current serialization format, then you have to change your format. You increase the version number (1_) to inform the unserializer which format has been used. On the unserializer method, you have to read first the format version first and then unserialize with this format (in order to make it compatible with old and current format). Of course you don't need to increase the format version number while the game is in test, it's only when your game is published and has already leveld created with the old format that you need to use this. I had to change my serializtion format many times for my games. Note that in the download package of the API for Flash 8, there is a a Serializer.as class that is very easy to use. Exple how to serialize and unserialize an array of number var serializer:Serializer=new Serializer(""); // Serialize the level data serializer.writeNumber(0); //serializtion version number serializer.writeNumber(dataArray.length); //write first the length of the array //write array elements for (var i:Number=0;i<dataArray.length;i++) { serializer.writeNumber(dataArray[i]); } var levelDataString:String=serializer.serialized; //Here is the string to send to the BL API //Unserialize serializer=new Serializer(levelDataString); var versionNb:Number=serializer.readNumber(); dataArray=new Array(); var nbElements:Number=serializer.readNumber(); for (var i:Number=0;i<nbElements;i++) { dataArray[i]=serializer.readNumber(); } You can do it, but personally I find it easier to use a system based entirely on numbers. But instead of using two digits, can I use letters as well as numbers? so: [1,1,0,1,a,d,1,a,0,0] As for how to store your array data as a string, it depends on what kind of array you're using and what kind of data it holds. Ultimately, you need to be think about how your going to take the string data the api gives you and turn it back into an array. You should build your string in a way that best fits that. Let's say your level data is contained in a single dimension array made only of 1's and 0's. You wouldn't need a very complex structure for this at all. Your sting would only need to be something like "0010101110" Later on, when you need to turn this string back into an array, all you'll need to do is myMap = leveldata.split(); and myMap will be an array full of 1's and 0's. Although, these 1's and 0's will still be strings, so you'll have to loop through that array and change them into number values. Now, lets say that your level data looks something like this: [1,1,1,10,0,1,0] When you turn that into a string, it would become "11110010" And then using the split function would turn it into an array with the values [1,1,1,1,0,0,1,0] As you can see, the number ten gets lost. We need a way to differentiate between the numbers. In this case, it is best to put commas between all your numbers when turning them into a string, so your sting will look like "1,1,1,10,0,1,0" Then when you need to turn this back into an array, you can use the function myMap = leveldata.split(","); and it will return an array identical to your original array. (although you will still need to loop through and turn all the strings into numbers) This works great for single dimensional arrays, but what if our level data is stored in a multi-dimensional array? For example myMap = [[2,2,3],[1,1,0]]; For this, I recommend adding comma's between all the array elements and |'s between the arrays themselves, so your string should end up looking like this "2,2,3|1,1,0" This way, when it comes time to turn this string back into an array, all you need to do is myMap = leveldata.split("|"); then loop though the elements of myMap, splitting them at "," and then turn those values into numbers. Good level data is only defined by how well and accurately you can turn it back into an array. You should always build your string structure with this in mind. Also, about blinit(). How should I make the game play the introduction only when the API had loaded? So is this good level data? I will ask for help with unserializing the data and all that stuff later... [0,0,1,0,1,1,0,3,0,0] Your engine needs to know where to split the data. If there's nothing between each number, it will think that it's one huge number ... My data looks like this: 1,1,3,0,4,1|1,1,2,4,7,1|1,1,3,0,4,1 - (ALL CREDITS GO TO CAPTAIN_404!) | Flash game developmentFirst post of the topicOkay, I would like to know how to create the level data, and load it, and make all the objects work, and a lot of other stuff too. I think I might have started too early, but I was dying to make a game for BL, and I can't really give up now! So basically I would like to know how to make a tile based map, that opens up on the screen when you play the game, or something like that. I might be able to manage it myself if the game was not for BL, but using the API and making arrays are two completely new things to me! |