Part of a sprite into another sprite or canvas?

New releases and general discussions.

Post » Tue Feb 16, 2010 1:38 am

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. :D

Thanks for any help pointing me in the right direction.

Krush.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Tue Feb 16, 2010 2:04 am

Ok, I seem to have found the solution just after writing the above post. :lol:

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. :cry: :cry:

Back to the drawing board.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Tue Feb 16, 2010 11:31 am

viewtopic.php?f=16&t=5772

Hope it helps! If you find out how to copy canvas contents into a sprite, let me know :)
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Tue Feb 16, 2010 4:21 pm

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.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Tue Feb 16, 2010 7:13 pm

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.
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Feb 18, 2010 12:31 am

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.
B
2
S
2
G
3
Posts: 406
Reputation: 2,062

Post » Thu Feb 18, 2010 6:26 am

You can also do some cropping with a distort map by setting the U, and V to 50.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249

Post » Thu Feb 18, 2010 8:14 am

[quote="newt":3q15ijx1]You can also do some cropping with a distort map by setting the U, and V to 50.[/quote:3q15ijx1]
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. :(
B
62
S
21
G
12
Posts: 1,910
Reputation: 13,155

Post » Thu Feb 18, 2010 4:43 pm

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.
Image Image
B
161
S
48
G
89
Posts: 7,347
Reputation: 66,249


Return to Construct Classic Discussion

Who is online

Users browsing this forum: No registered users and 5 guests