Sprite cropped size

Get help using Construct 2

Post » Mon Feb 27, 2012 7:13 am

Hi,
How do i get a sprite frame's cropped size? I know I can get the object size (.Width) and the original sprite size (.ImageWidth), but I need to get the real, current frame's width after it's been cropped in the editor.

(In case you're wondering why, I'm using it for a variable spacing bitmap font. Should be really easy if there's a way to get that value per frame).

Thanks!
Leo.
B
5
S
1
G
2
Posts: 8
Reputation: 1,271

Post » Mon Feb 27, 2012 4:29 pm

It would be ".ImageWidth" since cropping changes the image.
B
79
S
24
G
52
Posts: 4,725
Reputation: 39,713

Post » Tue Feb 28, 2012 5:11 am

Yes, but ".ImageWidth" seems to only return the width of the first animation frame. I need it to return the width of an arbitrary frame within the animation, or even the last frame used.

I'm assuming it can't be done, unless someone writes a plugin :-(

Thanks!
B
5
S
1
G
2
Posts: 8
Reputation: 1,271

Post » Tue Feb 28, 2012 10:11 am

[code]System: on start of layout
Local number curFrame = 0
-> System curFrame = Sprite.AnimationFrame
-> Sprite: set frame to 4
-> Text: set text to Sprite.ImageWidth
-> Sprite: set frame to curFrame[/code]

Doesn't work?
B
60
S
22
G
14
Posts: 1,479
Reputation: 16,346

Post » Tue Feb 28, 2012 11:09 am

> every tick > .imageWidth didn't worked?
ImageImageImageImageImageImage
B
92
S
19
G
12
Posts: 1,192
Reputation: 18,276

Post » Tue Feb 28, 2012 7:32 pm

I don't have my computer around right now, but maybe the issue is that I'm not updating every tick? The sprite objects containing the characters are created at the start of layout only, for performance reasons.

I'll try what Telles0808 suggested and update it on every tick... but I really think it shouldn't matter, you should always get the post-cropped size using .ImageWidth regardless of when.

Thanks!
Leo.
B
5
S
1
G
2
Posts: 8
Reputation: 1,271


Return to How do I....?

Who is online

Users browsing this forum: No registered users and 18 guests