How do I paste a specific instance of a family onto a DrawingCavas?

0 favourites
  • 6 posts
From the Asset Store
A collection of various zombie characters sprites for creating a 2D platformer or sidescroller game
  • Hi there, so I have a drawing canvas which I'm looking to fill with the object that is overlapping a select icon elsewhere in the layout.

    So if the select icon is overlapping Object X, then Object X is pasted into the Drawing Canvas

    If it's overlapping Object Y, then it pastes Object Y etc etc

    All of these Objects are in a family called Items

    I hope someone can point out the correct way of doing this, as it's just not 'clicking' for me.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Something like this:

    SelectIcon is overlapping Family
    .. Canvas set position to (Family.BBoxLeft, Family.BBoxTop)
    .. Canvas set size to (Family.width, Family.height)
    .. Canvas paste object Family
    

    Note that pasting is not instant, you need to wait a tick or two before removing the sprite or the canvas.

  • Hi dop2000 thank you for replying. Appreciate you taking the time out.

    When I use that, that will move the Drawing Canvas to the item?

    What I'm after is for the DrawingCanvas to mirror the object currently overlapped by the select icon.

    So if the select icon is overlapping Object X

    The DrawingCanvas will show Object X and the DrawingCanvas will keep its original position.

    Hopefully that's a little clearer.

  • To paste an object onto Drawing Canvas, it needs to be on the Drawing Canvas, or at least partially overlapping it. So you need to move the canvas to the object position, or move the object to the canvas position. Then paste, then return back.

    Alternatively, you can create a copy of the item (another sprite instance with the same animation) on the canvas. Then paste it, then destroy that instance.

  • Ah, gotcha. Thanks for explaining dop2000

    So I have this and it looks like it's working ...

    However, the canvas isn't clearing at all. Am I doing something wrong?

    On further investigation, it looks like it's not pasting the item onto the canvas at all and is just creating the items.

  • It's hard to tell by that screenshot what is wrong. Try clearing the canvas to some color, for example blue - grba(0,0,100,100). This way you'll see where it is. Also, like I said, pasting is not instant. You need to wait before destroying the pasted sprite. Try adding Wait 0.1s after Paste action.

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