Two yes/no questions

Discussion and feedback on Construct 2

Post » Wed Oct 08, 2014 6:47 pm

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?
Proud Construct 3 subscriber.
B
23
S
5
G
5
Posts: 207
Reputation: 4,693

Post » Wed Oct 08, 2014 7:11 pm

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.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Wed Oct 08, 2014 7:46 pm

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.

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?

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!
Proud Construct 3 subscriber.
B
23
S
5
G
5
Posts: 207
Reputation: 4,693

Post » Wed Oct 08, 2014 7:51 pm

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

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

Yes

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.
ImageImageImageImage
B
158
S
66
G
43
Posts: 2,603
Reputation: 35,868

Post » Wed Oct 08, 2014 8:13 pm

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Wed Oct 08, 2014 10:43 pm

Ashley wrote: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!
Proud Construct 3 subscriber.
B
23
S
5
G
5
Posts: 207
Reputation: 4,693

Post » Thu Oct 09, 2014 12:40 pm

Bob Thulfram wrote: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.

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.
Scirra Founder
B
399
S
236
G
89
Posts: 24,519
Reputation: 195,351

Post » Thu Oct 09, 2014 10:12 pm

Ashley wrote:
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!
Proud Construct 3 subscriber.
B
23
S
5
G
5
Posts: 207
Reputation: 4,693


Return to Construct 2 General

Who is online

Users browsing this forum: Google [Bot] and 4 guests