Dalal's Forum Posts

  • Hi Angroid! Have you considered using arrays to store your answers? From what you've said, I think that's a better solution. Once you're using arrays, you can use the "Download" action to save it to a file (JSON), or do whatever else you want with the data.

  • llfstudios Modified the old CocoonJSAds plugin to return the model name, and compared against that. Now that Cocoon.IO is out though I'll have to make some changes for the next version. Thanks for trying out the game!

    abdellah Thank you for the kind words! The elastic effect is actually just animation. There's around 3 (I think) sets of the wobble animation for different lengths, and in game we choose which animation to display based on the length of the line drawn, so it makes it seem like there's some physics action but actually it's just animation that tries to strike a balance between memory use and reasonable-looking springiness.

    grigrizljac Thank you!

  • Subscribe to Construct videos now

    | App Store | Google Play | Press Page | hello (at) nisuboy.com

    Bounce Sir is my first completed Construct 2 mobile game, which I worked on with my awesome little brother (that graphical genius). It's free! So go play it and spread the love! (and celebrate my two years of isolation, unexpected challenges, and self-discovery).

    Is it interesting at all?

    At a glance you might think it's another "endless runner", and you would be right. But also not right. What's weird about it is the super talkative main character (he talks... a lot... about everything), and the philosophical narrative that unfolds as you reach higher scores. "Flappy Bird" with existential angst? Maybe, but let's not get too weird.

    The game in a sentence?

    O bullickshtor!

    Thanks to you for checking it out! Do leave a comment and share your thoughts!

  • Sounds pretty interesting. I sent you an e-mail

  • I was surprised at first, but now I think this only applies to comments on blog posts or tutorials, because those are upvotable.

  • Thank you for the reply Ashley !

    I recognize that Canvas+ is not officially supported, but my choice to use it is well-informed. To me, what makes Construct 2 wonderful is not simply the workflow or the 'officially supported platforms', but the open architecture that makes it easy to tailor the output to one's specific needs. In my case, it allows me to easily add features for a deprecated non-browser wrapper. How can Construct 2 be any more awesome?

    That said, could we revisit the code I've written and why it may not be working how I expect? All I wanted here was a push in the right direction or a thumbs-up-that-looks-fine from someone that understands Construct 2's Audio object well and perhaps some of how Cocoon works as well. You are one of the best people to give me this feedback and if you find the time to reply again, your help and general comments on my code would be immensely appreciated.

    In addition, it could be that my code is correct Construct-2-wise, in which case I may have used Canvas+'s dispose() overload incorrectly. I've seen that ludei is sometimes active around here, so some feedback from them would also be very helpful.

  • My mobile game has a lot of sounds in it (voice clips) which drive the memory up a little more than I'd like. I'm using Cocoon Canvas+ to port to mobile, and it is said to contain a dispose() overload on all Audio objects. I'm trying to use this function to dynamically load/unload sounds as I need them.

    I started by adding an "Unload By Name" action to the Audio object of Construct 2, and its code looks like this:

    Acts.prototype.UnloadByName = function (filename)
    {
    	// only unload if we are in CocoonJS
    	if (this.runtime.isCocoonJs)
    	{
    		var src = this.runtime.files_subfolder + filename.toLowerCase() + (useOgg ? ".ogg" : ".m4a");
    		
    		// unload it
    		var instance = this.unloadAudioInstance(src);
    	}
    }
    
    instanceProto.unloadAudioInstance = function (src_)
    {
    	// Try to find existing instance from the same source
    	var i, len, a;		
    	var bufferToDispose, instanceObjectToDispose;
    	var foundInstance = 0;
    	
    	for (i = 0, len = audioInstances.length; i < len; i++)
    	{
    		a = audioInstances[i];
    		
    		if (a.src === src_ && (a.canBeRecycled() || is_music))
    		{
    			// DEBUG:
    			console.log("Found instance");
    			
    			// locate existing instance's objects
    			bufferToDispose = a.buffer.bufferObject;
    			instanceObjectToDispose = a.instanceObject;
    			foundInstance = 1;
    			
    			// now remove this audio instance completely and free it up for 
    			// garbage collection using iterative array slice code on Scirra blog:
    			// https://www.scirra.com/blog/76/how-to-write-low-garbage-real-time-javascript
    			for (var x = i, newLen = len - 1; x < newLen; x++)
    			{
    				audioInstances[x] = audioInstances[x + 1];
    			}
    			audioInstances.length = newLen;
    			
    			console.log("Length is now: " + audioInstances.length);
    			
    			// we're done with this loop
    			break;
    		}
    	}
    	
    	// now there are no references to audio, dispose it using Canvas+ dispose overload
    	if (foundInstance == 1)
    	{
    		bufferToDispose.dispose();
    		instanceObjectToDispose.dispose();
    		console.log("Disposed it.");
    	}
    };
    [/code:2hb21i2u]
    Now I'm sure I didn't do it perfectly, because I don't yet completely understand how Audio works, but I tried to make sure to dispose of anything that could potentially contain loaded audio (i.e the "buffer" and the "instanceObject"). I made a test project which uses this function, and here's what I have working (in essence):
    
    There are about 30 individual voice clips that can be loaded. To load a voice clip, you select it and then either Press "Play" or "Preload". Both seem to do the same thing in terms of loading a clip into memory. To unload a voice clip, you select it and then press "Unload". Now, here is what happens when I try it out:
    
    At program start, memory use stabilizes at around: [b]72.14 mb[/b]
    
    Once I load all 30 clips into memory, I get: [b]88.70 mb[/b]
    
    After I unload all of them, I get: [b]81.50 mb[/b]
    
    After loading all 30 again, I get: [b]81.64 mb[/b]
    
    At this point, no matter what I do, memory stays: [b]81.64 mb[/b]
    
    My question, to anyone that knows anything about memory or anything about Cocoon or Construct 2 Audio, such as @Ashley or @Ludei:
    
    What exactly could be happening here? Why is it that when I unload everything, only half of the allocated space is released? Is there one more secret Audio object that I didn't dispose of? How come once I've unloaded them the memory use doesn't change much? What am I not understanding? I feel like the answer lies in how Ludei's engine works, or how Construct 2 works. I hope either the developers or someone else knowledgeable in this can help me, so I can start better managing memory in my game.
    
    Thanks!
  • I realize this is an old post, but I have the same question.

    Can anyone explain how to decide the best numbers to put here?

    Any help at all will do! Thanks.

  • My menu layout takes up to 3 seconds to start (on mobile through CocoonJS Canvas+). In this time, I'd like to have an animation on screen that tells the player its loading. The problem is that the game freezes while loading the layout, so all animations appear still, and I'd be restricted to a static image. Also, it seems loader layouts do not work on Canvas+.

    Anyone have any clever solutions or ideas?

  • You need to sign and align your APK before it can be uploaded to Google Play. Here's how I've been doing it, but it's been a while since the initial installation so you might have your own hurdles and discoveries. It was a slight PITA to get this set up, but once you get the through the initial part the process is quite fast each time you need a signed/aligned APK.

    To sign it, you'll need the "jarsigner" tool. To install that tool, just get the latest Java JDK.

    To align it, you'll need the "zipalign" tool. To install it, get the latest Android sdk and then find the zipalign.exe file somewhere in the installation (I forget where it is). Ultimately, make sure you have zipalign.exe sitting in Android\sdk\tools.

    So now, you'll need to create a keystore which will be used to sign the APK. I don't remember how I made mine, but I've linked to some tutorial that will hopefully work for you.

    Now, here's what I have done to make this process easy for myself (I don't know if this is the best way or anything, I feel like I'm clueless on the whole, I'm barely getting by). In the root of E:\, I place my keystore file. Each time I have a new unsigned APK, I also place it here and call it Unsigned.apk or something to that effect.

    Now, I have a text document called "SignAndAlignScripts.txt", which contains the following text, including line breaks:

    jarsigner -verbose -keystore E:\mykey.keystore -storepass MY_PASSWORD -keypass MY_PASSWORD E:\Unsigned.apk MY_COMPANY
    
    zipalign -v 4 E:\Unsigned.apk E:\SignedAndAligned.apk
    
    [/code:11rbjv4z]
    The first part signs the APK, and the second aligns it. By pasting that text into command prompt, it'll automatically run both events and you'll wind up with a SignedAndAligned.apk that you can upload to Google. There's probably an easier way, like in a batch file or something so that you just have to double-click it, but the bottom line is that it's convenient to have a script to make it all one process. Now every time I need a new signed-aligned APK, I just place my unsigned file in E:\, name it appropriately, and then run this script. Voila, easy signed/aligned APK.
    
    Disclaimer: I have only very little clue of what I'm doing, learning lots along the way, like you. There may be a far better way, so wait a little while in case there's a better response <img src="{SMILIES_PATH}/icon_razz.gif" alt=":P" title="Razz">
    
    EDIT: I think I found the tutorial I followed. It was on Scirra all along. Follow that and you should be good to go! [url=https://www.scirra.com/tutorials/861/how-to-sign-and-align-your-android-app-apk]https://www.scirra.com/tutorials/861/ho ... id-app-apk[/url]
  • Tokinsom, thanks! And hey, did you still need loop points in your games? If your games are for web, and you're okay with placing your music in the Sounds folder, then the hack I was experimenting with will work for you just fine in modern browsers. Let me know if it would be useful to you and I can send you what I have.

  • Currently not too sure about Web Audio myself, but I came across this exciting stuff in the AudioBufferSourceNode specification:

    [quote:3n5a7ous]

    AudioBufferSourceNode.loopStart

    Is a double value indicating, in seconds, where in the AudioBuffer the restart of the play must happen. Its default value is 0.

    AudioBufferSourceNode.loopEnd

    Is a double value indicating, in seconds, where in the AudioBuffer the replay of the play must stop (and eventually loop again). Its default value is 0.

    Okay, I'm fairly certain the Audio object uses AudioBufferSourceNode. So somebody should be able to hack it in (I'm not the best, but I'm trying...).

    PROGRESS:

    • Got it to loop using the loop start! The song has to be played as a Sound for this to work, since Music doesn't use the Web Audio API. Testing some more stuff out, and then I'll post up a new Audio object here with some looping functions.
    • Bad News: It didn't work for me in mobile through Cocoon Canvas+, since it's using normal HTML-5 Audio, not the Web Audio API. so for my purposes this particular hack won't work. Still going to mess around some more and see if I can get anything working in Canvas+.
  • I've made some music that contains an intro sequence and then a loopable part. The idea is that I'll start by playing the intro and as soon as it ends I'll play the loopable part and repeat that indefinitely.

    My attempt so far plays the loopable part during an "On Ended" trigger (I figured that a fraction of a frame's lag before it plays the loopable part won't be noticeable). The problem is that it takes longer than a frame to play the loopable part, and there's a noticeable pause in between.

    Any ideas on how to queue the second track so that it plays immediately after the first?

    NOTE: The loopable part loops perfectly. It's just this intro-to-loop that needs fixing.

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • This seems to be an issue with particular devices, especially Samsung devices. On my phone, for example, I've tried some AAA sort of games that also have this delay. There are also some, like Cut The Rope, that don't have this delay, which means they used Android audio a different way either intentionally (to avoid the delay) or it just happen that way.

    Unfortunately, I don't think this is ever going to be resolved for our phones, so we'll have to accept it. Don't worry, half the people I've tested my game on don't even notice that anything's delayed

  • Glad to hear that I'm not the only victim! I guess that warrants a bug report.