Toby R's Recent Forum Activity

  • 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?

  • 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.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

Toby R's avatar

Toby R

Member since 23 Mar, 2015

Twitter
Toby R has 18 followers

Connect with Toby R

Trophy Case

  • 9-Year Club
  • Forum Contributor Made 100 posts in the forums
  • Forum Patron Made 500 posts in the forums
  • Forum Hero Made 1,000 posts in the forums
  • x6
    Coach One of your tutorials has over 1,000 readers
  • Email Verified

Progress

14/44
How to earn trophies