Sprite cropped size

  • 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.

  • It would be ".ImageWidth" since cropping changes the image.

  • 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!

  • 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

    Doesn't work?

  • every tick > .imageWidth didn't worked?

  • Try Construct 3

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

    Try Now Construct 3 users don't see these ads
  • 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.

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