How do I force construct to only pre-render current frame of an animation?

0 favourites
  • 5 posts
From the Asset Store
Build a thrilling space station scenario with these level assets and characters.
  • I am using the Spriter add-on to draw characters in my game, and one of the key features of Spriter are "character maps". In character maps, different outfits/weapons for your character can be easily swapped out across your entire animation by swapping out the body-part images.

    In construct, this is implemented by the different 'character maps' existing as different animation frames for the sprite that represents your body part. For example, your Spriter object contains a single sprite for your chracters weapon, and that sprite can have many animation frames, each containing the image for a different weapon. For example a dagger, sword, axe etc. will all be stored as different animation frames within your single weapon sprite.

    This system is very easy to work with, however it faces the issue of memory use when having a lot of different items available for your character. My understanding is that this problem is caused due to the fact that construct always pre-renders every animation frame of every sprite on screen.

    This makes sense for any sprite being used as an animation in the typical sense, or even any sprite that will need to regularly change animation frame, but here it is problematic. For example, say my character has a special sword that only gets unlocked at level 99 after 5 hours playing the game. Despite this fact, construct will be pre-rendering that sword every time my character is on screen for the first 5 hours, despite the fact that it will never be shown. More than that, it will be pre-rendering every piece of equipment my character can use every time it is on screen, even if 99% of those items may not be needed at all the majority of the time.

    So my question: is there any way to force construct to only pre-render the current animation frame of a sprite for this specific circumstance? In my case I think it would be well worth the sacrifice of significant 'jank' when swapping animation frames for that sprite, because that only ever happens very rarely on a specific 'inventory' layout.

  • quick question, doesn't spriter exports a animation file .plx or soemthing like that that includes the "frames inside" or the actual graphics? cause i remember i seen somewhere this thing where was using spriter or spline? not sure which one... i never used them, but anyway i seen this capx example where it loaded all assets animation + animation frame designs from 1 type of .something inside the project, like a inner rar inside construct type of thing, and that thing was fast as like insane fast. is this spriter addon thingy doing that? or i dreamt this feature?

    cause that might be your solution, now i don't know if was spriter, spline, or dragonbone ... either one they all do the same thing, so im guessing they all should have the same capabilities as exporting ?

  • Hey, Spriter exports a .scon file which as far as I am aware just contains all of the animation instructions for your sprites. All the individual sprites are then bundled into a zip that you import into your project.

    The performance in-game is actually great, and swapping between character maps is instant, it is mainly just the loading time between layouts that is my problem - when I go to load a new layout with a spriter character on it leads to a delay.

    This can be solved by reducing all the image sizes down a lot, but obviously this leads to a big hit in quality in terms of how the game looks.

    I know trade-offs like this are typical, it would just be great if there was a way to avoid it.

  • In case anyone ends up here from a search: I believe Spriter actually has this functionality built into it when using the "draw self" mode for your spriter objects. This is a different import method than I was using, as you need to export your spriter file as a spritesheet using these instructions:

    nycgio There is an additional way to import Spriter files in both C2 and C3. Instead of using individual sprites, the plugin draws all of the images itself. The plugin runs much faster and uses less ram with this method, so unless you need separate sprite objects (for instance, to add an effect to some of the sprites that make up your character, but not others), you should always use this method. The import process is completely different than the other method. It looks like a lot of steps, but it's easy and quick to do once you know how.

    The first step is to have Spriter figure out the bounding boxes of each animation. This tells the scml plugin how much space it needs to draw each animation.

    To do this, click here:

    Use these settings:

    You only need to do this the first time you export it, or when you add a new animation. This only affects the bounding box of the animation (anything outside this box isn't drawn), so if you're tweaking animations and testing the game repeatedly, you don't need to do this every time.

    Make sure you have these options enabled in Spriter:

    When you're ready to export, go here:

    The settings I've marked in red are all mandatory. The other settings on the left you can tweak as you like. Spriter saves all of the settings in this dialog, so you don't have to check these every time.

    Next, click the dots next to base filename to choose the filename. You need to save it to a separate folder from your main project, and the filename you choose will apply to both the spritesheet and the scon file. Click Ok to complete the export.

    In Construct 3, create your scml file as you would any other object. Right click - insert new object - scml.

    When you add the object, C3 will open up the image editing dialog the same way it does when you add a standard sprite object.

    In the image editing dialog, click the folder icon to load an image, and choose the spritesheet png that you just exported.

    Import the corresponding scon file by right clicking on Files in the Project Pane and choosing Import Files, and selecting the file:

    And lastly, in the properties pane, set scml filename to the name of the scon file, and make sure that draw self is set to true.

    That should do it. Lemme know if you have any issues.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • dmt10 see told you there is something that allows spriter to export its own textures and should be fast on map swap of character ;)

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