Hello Guest

Author Topic: Setting the borders of a Sliced Sprite  (Read 4165 times)

Cheruby

  • Newbie
  • *
  • Posts: 1
    • View Profile
Setting the borders of a Sliced Sprite
« on: June 04, 2014, 03:38:24 pm »
Hello,

I tried looking up the SetBorder function for a Sliced Sprite because it popped up while I was coding but didn't see it in the scripting manual.

I found the code that does it:
Code: [Select]
public void SetBorder(float left, float bottom, float right, float top) {
if (borderLeft != left || borderBottom != bottom || borderRight != right || borderTop != top) {
borderLeft = left;
borderBottom = bottom;
borderRight = right;
borderTop = top;

UpdateVertices();
}
}

Now my problem is that I'm trying to set the borders to 5, 5, 5, 32 (left, bottom, right, top respectively).
Instead it gives me this during 'Play': L = 580, B = 580, R = 580, T = 3712.

Am I missing something? I'm not sure why the numbers are so inflated.

Thanks!

*** EDIT UPDATE ***
I'm not sure if it's a feature or a bug or both  ;) (I solved my issue for now):

My sprite is 116x116 in pixel size.
The border would multiply the value you give in SetBorder() to those pixel values.
I tried it with values of 10f and 1f. It would give me 1160 and 116 respectively.
« Last Edit: June 04, 2014, 05:30:42 pm by Cheruby »

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Setting the borders of a Sliced Sprite
« Reply #1 on: June 04, 2014, 08:14:50 pm »
Border values are in the 0..1 range. So if your texture is 116 pixels and you want a border of 8 pixels, the value will be 8.0 divide 116.0 which is 0.068965517. It stores the fraction to be agnostic to the size of the actual texture.