Part of a sprite into another sprite or canvas?

This forum is currently in read-only mode.
From the Asset Store
Basic template for drawing game with masks and easy customization
  • Here's one for you guys.

    Is it possible to have a sprite (say 300x300) and display part of it (say 50x50) in a 50x50 sprite or canvas?

    I have a feeling that the answer lies with the canvas, based on past conversations I've read on here, but I've hardly bothered looking at the Canvas object.

    There's a lot of Construct that I should explore more.

    If only there were more hours in the day.

    Thanks for any help pointing me in the right direction.

    Krush.

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • Ok, I seem to have found the solution just after writing the above post.

    For those who find this thread in the future, use the image manipulator to copy from the source sprite, crop it to the size of destination sprite at the location within the source sprite you need, and then copy to the destination sprite.

    Haven't done any performance checks on this yet, but I can't see any reason why it isn't going to be fast enough for what I want.

    Krush.

    EDIT: Ouch! That method is painfully slow, and of no use to me at all.

    Back to the drawing board.

  • Hope it helps! If you find out how to copy canvas contents into a sprite, let me know

  • Image manipulator can do all that. Note you cant copy from image manipulator to canvas, but you can copy from it, then again you don't really need to copy to canvas, since you can use paste object.

    Note image manipulator has many quirks about it, it seems you have to flip an image you copy from a sprite, and the crop feature...doesn't really work as expected.

    Edit:

    Also note it may take a tick to update some things since your working from the gpu... the function object is your friend.

  • Replace the Canvas with Image Manipulator, use another sprite to show the cropped image, have ImageManipulator copy from the big sprite, crop to the "box" area, copy to the other sprite.

    FPS plummets down to 14. So yeah, I'd prefer to work with Canvas with its 1900 FPS.

  • As I posted above, the image manipulator isn't going to be any good because I need it to be very fast.

    Mipey; Your example with the canvas works well, but I find the Canvas object very buggy.

    For instance, if I resize the canvas from your example in the editor, when it's run the canvas is nowhere near the size it should be!?!

    I've found another solution, and although it's not ideal, unless I can get the canvas to play ball, it will have to do.

    Cheers guys,

    Krush.

  • You can also do some cropping with a distort map by setting the U, and V to 50.

  • You can also do some cropping with a distort map by setting the U, and V to 50.

    You make it sound easy. Care to show an example? I can't get it to work properly for the life of myself. It is all pinchy and stuff.

  • Actually Im getting some weird results as well.

    + System: Start of layout

    -> Sprite: Set distort map size to 3, 3

    -> Sprite: Set relative displacement at (3, 0) to XYZ(0, 0, 0) UV(50, 0) 100 %

    -> Sprite: Set relative displacement at (3, 3) to XYZ(0, 0, 0) UV(50, 50) 100 %

    -> Sprite: Set relative displacement at (0, 3) to XYZ(0, 0, 0) UV(0, 50) 100 %

    Dunno, perhaps something has changed.

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