Two yes/no questions

0 favourites
  • 8 posts
From the Asset Store
This is a Dungeon Master tool & the 1st of 12 Combat Engines from the Building Combat Engines for Browser Games workshop
  • These may have been answered somewhere, but I only could find hints.

    1. Any chance of introducing Web Workers and multi-threading? Every browser supports it. Good for calculation-intensive games.

    2. When I was reading the How to Make a Platform Game tutorial by Ashley https://www.scirra.com/tutorials/253/how-to-make-a-platform-game/page-2, one of the comments made me think that if I import a sprite sheet but only use a few sprites from it, the while sheet goes into the game and takes up a lot of space. Is this correct? I kind of assumed that any sprites not used in a sprite sheet were discarded. I ask because I'm using some commercial sprite sheets that are quite large but I only want to use a dozen or so, not the several hundred in the sheet. Should I redraw the sprite sheet? If I just erase the sprites I don't want, will the blank parts of the sprite sheet still be pulled in? Or, if I go through the Animation frames window and delete any unwanted frames, my memory usage will be better?

  • 1. Web workers are already in C2. For example Pathfinding behavior is using it.

    2. If you are importing sprite sheet you are asked to specify number of horizontal and vertical cells. This numbers divide entire image and imports everything into animation frames - no matter if parts of the image are solid color or is transparent.

    You can modify original sprite sheet to contain only frames you want to import, or you can specify h and v cells to import everything and simply delete frames you don't need. just remember that sprites on the sprite sheet must be properly aligned or you can end up with a lot of funky looking frames.

    As for the memory part. If sprite is present on the layout then every single animation frame will be loaded into a memory.

    So if your sprite have 5 animations and each animation have 10 frames, all of the 50 frames will be loaded.

  • [quote:3kqa38w2]1. Web workers are already in C2. For example Pathfinding behavior is using it.

    Sounds like a good use. But there's no way to use workers in some other way on my own.

    [quote:3kqa38w2]You can modify original sprite sheet to contain only frames you want to import, or you can specify h and v cells to import everything and simply delete frames you don't need.

    Once a frame is deleted, it won't be in memory or part of the final export, right?

    [quote:3kqa38w2]As for the memory part. If sprite is present on the layout then every single animation frame will be loaded into a memory.

    So if your sprite have 5 animations and each animation have 10 frames, all of the 50 frames will be loaded.

    So if I have 10 copies of a sprite and each sprite has 10 frames (but only one animation), does that mean that 100 frames will be loaded into memory?

    I need to learn more about tilemaps!

    Thanks!

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • [quote:2cgqfotf]Sounds like a good use. But there's no way to use workers in some other way on my own.

    Not sure, maybe it's possible via plugins... only Ashley can say

    [quote:2cgqfotf]Once a frame is deleted, it won't be in memory or part of the final export, right?

    Yes

    [quote:2cgqfotf]So if I have 10 copies of a sprite and each sprite has 10 frames (but only one animation), does that mean that 100 frames will be loaded into memory?

    10 different sprites - Yes. Every 10 frames in each sprite will be loaded

    10 instances of one sprite - No. Only 10 frames will be loaded for one sprite and the remaining 9 instances will use already loaded images.

  • You can write a web worker in your own plugin if you think there's something that could benefit from it, but they are best suited for relatively long running tasks (like pathfinding, where it is already used). Posting messages between workers has some overhead so if the amount of work is small, the communication overhead will be larger than the work to be done, negating the benefit of using a worker. In a game engine there's not much that qualifies for that, most tasks are small and synchronous.

    Export-time image deduplication will remove identical images between object types, but it won't reduce memory use in preview, and it's more sensible to use one object type for one set of images anyway. All frames of all animations are loaded regardless of if they are used, as described in memory usage.

  • You can write a web worker in your own plugin if you think there's something that could benefit from it, but they are best suited for relatively long running tasks (like pathfinding, where it is already used). Posting messages between workers has some overhead so if the amount of work is small, the communication overhead will be larger than the work to be done, negating the benefit of using a worker. In a game engine there's not much that qualifies for that, most tasks are small and synchronous.

    Export-time image deduplication will remove identical images between object types, but it won't reduce memory use in preview, and it's more sensible to use one object type for one set of images anyway. All frames of all animations are loaded regardless of if they are used, as described in memory usage.

    Ashley, thanks for the links!

    Web Workers are cool. The best use I've seen for them are in BrowserQuest (http://browserquest.mozilla.org/ a MMO in a browser, where Web Workers are used to draw nearby areas before you walk into them.

    I've been using the technique you wrote about in your tutorial on Platform Games https://www.scirra.com/tutorials/253/how-to-make-a-platform-game/page-2 where you load in a sprite sheet as an animation and then drop the sprite objects into your Layout but change the image by choosing an index into the animation array. So it sounds like if I import a sprite sheet with 50 images, and I only use 10 images in the Layout, I'll still be charged for the other 40? Sounds like I'll have to redo my sprite sheet (except that I bought it from someone so copying the art to a new image might be a chore).

    Ashley Has anything changed for AUDIO since your last blog post, almost a year ago? https://www.scirra.com/blog/ashley/2/the-never-ending-issue-of-dual-encoding. I'm a big fan of OGG and it sounds like AAC is better than MP3 (both in quality and licensing for streaming), but what happens if you try to use Construct 2 on Windows before Windows 7? And has the Windows 7 AAC encoder improved? I don't have any more copies of Windows XP, but I'm still running Vista on an old Alienware PC - Dell refuses to write Windows 7 drivers! I'll see how Construct 2 audio runs on Vista.

    I really appreciate your championing of OGG!

  • So it sounds like if I import a sprite sheet with 50 images, and I only use 10 images in the Layout, I'll still be charged for the other 40?

    Yes. The tutorial you linked to was written before tilemaps were supported btw - it's a lot easier to use in the editor if you use tilemaps instead of sprite frames.

    [quote:35bbcvq7]Has anything changed for AUDIO since your last blog post, almost a year ago?

    Nope. Pre-Windows 7 you need to encode your own AAC. I don't think the Windows built-in encoder is still very good, so you might want to encode your own AAC anyway if audio quality is important.

  • [quote:1uakhcu8]Has anything changed for AUDIO since your last blog post, almost a year ago?

    Nope. Pre-Windows 7 you need to encode your own AAC. I don't think the Windows built-in encoder is still very good, so you might want to encode your own AAC anyway if audio quality is important.

    Good to know. If I encode my own AAC (and OGG), I'm good to go! THANK YOU!

Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)