Author Topic: [help] how to determine if snap is horizontal or vertical?  (Read 5677 times)

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
[help] how to determine if snap is horizontal or vertical?
« on: December 23, 2015, 06:02:26 AM »
how to determine if snap (or any other art) for current game is horizontal or vertical?

I would like to position and scale snap in background differently for vertical and for horizontal snaps - totally different set of coordinates.

something like this

if
snap_width/snap_height < 1
then
set of coorfinates #1

if
snap_width/snap_height > 1
then
set of coorfinates #2

liquid8d

  • Global Moderator
  • Sr. Member
  • *****
  • Posts: 442
    • View Profile
Re: [help] how to determine if snap is horizontal or vertical?
« Reply #1 on: December 23, 2015, 08:17:35 AM »
if you just want to go by the actual object width height it's just:

local aspect = image.width / image.height.tofloat();
if ( aspect > 1.0 )
{
   //wide
} else
{
   //tall
}

but are you concerned about the TEXTURE width height (i.e using preserve art)? If so, it's more complicated, because you have to first make sure that the texture width/height is known in a transition, then check the texture aspect. This is why I made the preserve-art module, and if you are using that you should be able to just go by the width/height of your object.

verion

  • Global Moderator
  • Hero Member
  • *****
  • Posts: 861
    • View Profile
    • new projects
Re: [help] how to determine if snap is horizontal or vertical?
« Reply #2 on: December 23, 2015, 08:56:00 AM »
I have to do this on every transition (snap change) and for the [snap] - but maybe I'll just adapt your preserve art approach. This way I can focus more on how-to-use-it, not how-to-code-it.
Thanks.