Toby R's Forum Posts

  • v1.5 update (2017-02-09)

    • Is value in set (Value, {item1, item2, item...}) condition added: Is true when Value is equal to at least one of elements in set.

    This is a small update yet with a very handy feature. Below you can see a comparison of some possibilities.

  • Hi thechriskent!

    Thanks for this one, it makes life much more comfortable!

    Just one thing. Could you please remove the

    console.log(this.charWidthJSON);[/code:3h2nioyl] from the [i]instanceProto.onCreate[/i] function? It really slows down object creation. I have leaderboards with thousands of entries and this one log slows it down by several seconds.
    
    I can remove it myself for my own needs, but it would be good to have it clean in the official version. I presume it's just a remaining of your testings?
    
    Cheers
  • I'm not quite sure if I understand what do you try to achieve exactly, but if you try to encapsulate data in an elegant way, you may want to take a look at Globals plugin approach http://tobyr.wtfgamesgroup.com/c2-plugins/globals-construct-2-plugin-alternative-for-native-global-variables/.

    You can create various instances to encapsulate specific data.

  • Hi Izzy28,

    Drop me an email (tobyr[at]wtfgamesgroup.com) with all the details please like what exactly are you trying to do, what is the expected behavior and what is the current effect. Also what wrapper and platform (and plugins if there are some custom) are you working with. Thanks.

  • Thank you for the great words Aserak2012, much appreciated!

    Thank you for your offer but I'm afraid I won't manage to fit any more side projects in my timeline as I'm mostly focused on freelance work now. Wish you a great success with your project!

  • I already do it by using a permanent object (say, an array) in my game instead of global variables. The problem is i just recently started this approach and still have tons of globals to turn into object variables with all affected events.

    That's why it is recommended to use this approach always from the start of the project (from the very first global variable) and have things encapsulated all the time. Refactoring the existing project is always time consuming. Still if you have "tons" of globals it most probably mean your app architecture is not the best it could be. Whenever it is possible you should use local variables instead of globals.

  • +1

  • Alright, it's clear now. Thanks for the info.

  • If you use separate sprites, and put each sprite on its own layout, the C2 engine will only load one at a time.

    The WebGL texture memory is explicitly released by the engine - GC does not play a part.

    Oh so it's handled differently than sounds. Good to know thanks. Also could you tell if the image/sprite buffer is released from the memory instantly once the object gets destroyed or after switching layout?

    I know that you wrote in the article about memory that it gets released from the memory after layout switch (if it doesn't exists on the next layout), but I'm not sure if it's about the sprites which are on the layout till the layout switch or does that rule fit sprites destroyed during layout as well?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • There is a difference.

    If you put all images into one sprite as an animation then all images will get loaded into the memory at the start of the layout together with the sprite object.

    If you put each image into separate sprite and those sprites are not on the layout by default but are created one after another as you described (note that you need to have them on some separate layout to be able to create them with System -> Create object). Then initial memory usage will be lower as no images will be loaded.

    Now by creating a particular sprite you will load its image into memory. By destroying the sprite you are dropping the object's reference which is like a "you can take it away" flag for JavaScript GarbageCollector.

    The point is that there is no way to manually call the GC in JS, so if it happens that GC comes when you're watching 5th slide for instance, then it will release first four images from the memory as they are destroyed and nothing is pointing at this part of the memory any more. But GC may also not come during the whole slideshow. So this approach takes less memory initially and may take less in general, but it's not 100% promised... depends on GC.

  • This type of plugin is really bad for compatibility for all the reasons described here.

    I know people need these features, and sometimes people need them sooner than we provide them. However if it is remotely possible, the plugin should be minimal code to patch code in to another plugin. It's not always possible, but when you take this "copy and paste" approach and copy the entire plugin wholesale, you can easily create worse problems than the plugin aims to solve.

    I totally agree. That's why we ask you to add those extra features to the official Audio plugin. AudioPlus is not released as a completed addon. It's experimental just to test the possibilities of releasing the memory. I am not keen (and I'm not about) to maintain this or keep it as my official plugin for obvious reasons (like those listed in your article).

    But as far as I am aware those features were requested over a year ago. Still official Audio doesn't have releasing memory implemented and that's why I gave it a try to see if it's really that problematic to implement. It looks like it works, added just few functions. For some projects this feature is an absolute must-have, so even tho this is an experimental addon, I would personally rather to launch my game with such plugin than not be able to launch my game at all.

    Anyway, it's here and it works and we ask you to implement those into the official plugin. I know you're a busy man so I hope my code will save you some time if you decide to use it, and we (C2 devs) will have it in Audio plugin.

  • awesome plugin! but im not sure if wold be good as clearing the "garbage" or buffer cache wold basically make people redownload the buffer each time the same song/sound plays therefor increasing lagging/buffering time... the normal audio seems more suited for games.. while this plugins seem something you wold use in a particular project.. where clearing buffer wold increase performance and then never to use the particular sound again.

    great job! but not for me!

    Of course it is pointless to release the buffer of the audio which you will use later in game. This feature is for bigger projects which have many unique audios per level.

  • Thanks for the great and detailed wrap-up of the plugin TheRealDannyyy!

    BTW: here's a short test of sound unloading I made with TheRealDannyyy 's tool (so you could see how much memory it can save):

    Subscribe to Construct videos now

    Ashley I saw you said:

    I'll try and get audio unloading in the next build...

    That's awesome. I know you can handle this yourself, still if you find the snippets from AudioPlus plugin useful you're obviously free to put them in the official plugin. I've used a lot of official code anyway.

    One additional thing. Because of unloading features, the common approach will be now to not preload all sounds and startup but load them selectively. Therefore I was planning to add On sound preloaded condition. But as you're planning to add it to the official one, I'll pass with this one. Still it would be great if you could implement such condition to the plugin so C2 devs could make nice visual preloaders.

    Thanks

    EDIT - Updated YT URL above, now it has much better quality.

  • We have a cool guy called AndreasR here who answered your question before you even asked. That's how cool he is

  • You must be very careful when working with version control and C2. I don't think there is any automated way to combine two projects which vary so much (unless you understand C2 XML perfectly and write your own merge script). So I'm afraid you have to do it manually.

    Next time remember to work on the same project/repo from the start. When you start work, always make an update from repo before you open C2. Commit when you're done. But that's not all. You have to avoid working on the same parts of the project at the same time. There are situations where SVN/GIT merges the code without any issues but new code will be corrupted for C2. Changing object name, adding behaviors etc.