DrawingCanvas - is there a way to paste sprite/tile without having to wait?

Not favoritedFavorited Favorited 0 favourites
  • 9 posts
From the Asset Store
Each tile 64 by 64 pixels - Ultimate Tile Set for your awesome games
  • So I have a sprite in layout B and I want to create the sprite in layout A via actions so that I can use the DrawingCanvas object to paste it and make a replica visually.

    But since it has not been rendered at all.. I have to wait atleast 0.1s after creating it so that I can paste the sprite. This doesn't happen if the sprite was already in the layout.

    Is there any other way I can create the sprite without having to wait because there're a lot of sprites and I cannot set them all on the layout.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • That's how Construct works - if the object doesn't exist on this layout, it takes time to load its texture. You can try running "System Load object images" action in advance. A wait will still probably be required, but you can reduce it from 0.1s to a single tick - "Wait 0".

    But the best solution would probably be keeping an instance of this sprite on the layout.

  • dop2000

    Hello, I added the action, but it still is not working.

    Yes I need the wait to reduce as much as possible but in my game, it will not be a good idea to set all sprites or tiles on the layout because there are 10-15 sprites and are nearly 400*400px which may affect performance.

    Maybe I did it wrong.

    Or I should do that on start of layout? But still there's too many sprites to be loaded in memory

    In construct 2, there were no such issue using the Canvas plugin. So this looks like a step down to me of how the DrawingCanvas works.

  • You need to load the image at least 0.5-1 second in advance, to be sure that it works on slowest hardware. And you still need to create the sprite before pasting it on the canvas.

    I would say 15 images 400x400 is not so bad, they will only take about 20-30 MB in memory. I would put them on the same layout.

  • Alright,

    For the time being, I'll put them in the layout, since it is working fine without any delay.

    I'll still file an issue later on why the Canvas plugin is working better in C2 compared to DrawingCanvas in C3. For Ashley

    Thanks! dop2000

  • You should use 'Wait for previous actions to complete', not 'Wait 0 seconds', as you want to make sure the previous actions have actually finished. If you wait for any fixed amount of time, there is still no guarantee the previous actions have actually finished.

    Construct 2 did not have any official Drawing Canvas plugin - that was only introduced in Construct 3. If you were using a different third-party plugin then please note it's not something we're responsible for.

  • Ashley

    Hello, my issue is the render time before we can paste on the drawingCanvas object. I have noticed that when the object is on a grave layout and will be created on a new layout via code... it takes few m/s before I can paste it on the drawingCanvas. This is worst on low/mid end devices (Tested on J7, A30 and few others).

    1st solution is to add it to the layout itself but having too many objects will increase the image memory on low end devices. Right now I have approx 15 tiles. Later I might have 30 or even 50, so this solution is not the best.

    2nd solution is to use wait 0.1s if there's none of the sprite/tile on the screen. Or use "wait for previous actions" when creating and pasting... but this doesn't work all the time.

    Anyways... on C2, the canvas plugin was updated by R0J0hound and currently this is fast and works on low end devices without any issue.

    On C3, even though it is not the same plugin... it still is a step down for me, since the waiting time is so much visible on some devices; and players will see unintended items while the wait is in process (yeah even by m/s). The issue below happens when the sprite/tile is in grave layout and this works and sometimes doesn't, because it need to wait for it to render completely. It will work if I use 0.1s but I don't want to.

    I know that Construct 3 can do better. So please check it out.

  • If you create an object that is not placed on the layout, Construct loads its textures on the fly, and that can take a moment on low end devices. In that case the 'Create object' action is effectively asynchronous and you won't be able to immediately paste the object to a canvas, because the object hasn't loaded its textures yet, and so cannot draw itself.

    The easiest solution is to place the object on the layout, and destroy it on startup. Then Construct pre-loads its images when the layout starts. (See Memory usage in the manual.)

    Otherwise you can use the system memory management actions, e.g. the 'Load object images' action, before creating the object. Something like Load object images, wait for previous actions to complete, and then 'Create object' for the same object, will then ensure it is ready before creating and so it should be able to paste to a canvas straight away too.

    (FWIW Construct 2 loaded objects synchronously, and that could jank the game. Construct 3's approach ensures a smooth framerate and better performance loading lots of objects. This is not 100% compatible with C2 projects though and so is a documented compatibility issue moving from C2 to C3.)

  • Ashley

    Okay, I understand now. So it's more about how C3 handles the creation/loading of the objects.

    I'll stick to this like before... "The easiest solution is to place the object on the layout, and destroy it on startup"

    Thanks.

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