How do I edit sprite pixels at run-time

0 favourites
  • 3 posts
From the Asset Store
An educational game for Times Table. An easy to use template for developers to build larger games
  • Hi, I've been searching for this but haven't found an answer yet.

    Currently, if I create a demo with explosions or damage impact, I spawn small groups of tiny sprites which stick to damaged player, npc, or destructible sprite objects; as scorch marks or surface damage. These are pinned to the surface of a sprite until it is destroyed. These tend to be 4x4 pixel black or grey dots, so its a lot of resource having each one as a pinned sprite.

    A more effective way to do this would be to draw directly into the frames of the current sprite instance.

    E.g.

    bomb - on collision with - building ... thisBuilding.animations.frames(0).drawRect(x1, y1, x2, y2, colour_code)

    Is this possible in construct 3?

    Could I read a pixel colour value and use that to darken and increase transparency?

    Many thanks,

    Kinnon

  • You can paste your sprite onto a DrawingCanvas object. DrawingCanvas has some limitations comparing to Sprite (for example, you can't deform it, can't change collision polygon), but it should work fine for buildings and such.

    You can use a combination of both - an invisible PlayerBox sprite with the correct collision polygon etc., and a DrawingCanvas object pinned to it, acting as a "skin".

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ah, thanks dop2000. That sounds perfect, I'll try that. Didnt even realise C3 had a canvas object. Thats just opened up a whole world of possibilities!

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