How do I generate a picture from objects?

0 favourites
  • 4 posts
From the Asset Store
An educational game for counting pictures. An easy to use template for developers to build larger games
  • Hi,

    So in my game there's a little hero avatar picture appearing one screen multiple times at once.

    The avatar is composed of replaceable parts (hair, eyes, nose etc) -- the user creates it when first starting the game. It doesn't change ingame.

    I feel it would be way more memory efficient and generally better to have a static image for this avatar instead of spawning multiple (up to 200-300) copies consisting of ~10 elements pinned together.

    I was wondering what would be the best approach to just spawn the avatar once, then flatten it and use the image?

    Probably the way to do it would be to screenshot the avatar and create a sprite based on the image? I searched the forums and found that to screenshot part of the screen I'd need to resize the canvas back and forth which feels a bit clunky and I'm not sure if it's not noticeable for the user?

    Or maybe someone could suggest a better way?

    Thanks!

  • You can paste all sprites of the avatar onto a DrawingCanvas object. If you need it to be a sprite, you can then transfer the image from DrawingCanvas into an empty sprite.

    DrawingCanvas paste Face
    DrawingCanvas paste Eyes
    DrawingCanvas paste Nose
    ...
    Wait 0
    DrawingCanvas Save image
    Wait for previous action to complete
    EmptyAvatar load image from DrawingCanvas.SavedImageURL
    
  • That is great! Would you care to explain why the "wait 0" is needed there?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Objects are pasted at the end of the tick. It may not be needed, if "Save" also starts at the end of the tick, I don't know, you can try without the wait.

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