Setting the dimensions of all cards to match the stack

Getting into LiveCode for iOS? Ask your questions here.

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller, robinmiller

Post Reply
donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Contact:

Setting the dimensions of all cards to match the stack

Post by donbrae » Sun Jan 12, 2014 10:31 pm

Hi. I'm creating an iOS game and am configuring the layout of a card before actually going to it. However, the rect of the card reflects its rect when I last saved it in the IDE, when in fact I want it to match the rect of the actual device.

The card taking on the stack's dimensions appears to happen automatically when you actually go the card, but I need a way to have it happen before this stage, so I can lay elements out relative to the card's dimensions.

In the preOpenStack handler I have this directive:

Code: Select all

set the rect of this stack to the screenrect
It doesn't, though, appear to cascade down to cards until they are in view, and I believe you can't affect the dimensions of a card directly.

Anyone know if there's a quick way to do this?

Many thanks.
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by jacque » Sun Jan 12, 2014 11:16 pm

On mobile, all cards are automatically set to the size of the device; you don't have to set that in a script. To arrange the card objects, there are two approaches. If your stack has only a few cards, do the layouts in a resizeStack handler and cycle through all the cards at once. A resizeStack message is sent to the first card when the stack launches, and also every time the user rotates the device. The other option is to do the layout in a preOpenCard handler on each card. That message is sent on every card change.

I've used both methods.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by donbrae » Sun Jan 12, 2014 11:45 pm

Many thanks, Jacqueline. Useful information. I only have a few cards so I can try cycling through them in a resizeStack handler.

As I loop through the cards, is there any way to say "make this card the same dimensions as the stack", so that when I refer to it (post-loop), the dimensions reflect the stack's? If not, I can modify my approach and do a bit of refactoring.
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by jacque » Sun Jan 12, 2014 11:53 pm

Cards are always the same size as the stack window. You don't have to do anything, it just happens.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by donbrae » Mon Jan 13, 2014 12:20 am

Thanks, Jacqueline. Interesting. A quick example...

When, in the iOS Simulator, I'm on card 1 and I read the width of card 2, the value I get back is whatever the width of card 2 was in the IDE. However, if I read the width of card 2 when card 2 has opened, it matches the width of the device. Is that what's supposed to happen?

Just wanted to be sure before I spend time rewriting my code :)

Many thanks.
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by donbrae » Mon Jan 13, 2014 12:28 am

I may actually, in any case, be able to do the layout on a default screen size and use the new fullscreenmode feature in 6.5 rather than going through all my controls and sizing and positioning in relation to the device size.
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

Jellicle
Posts: 453
Joined: Thu Feb 24, 2011 11:07 am

Re: Setting the dimensions of all cards to match the stack

Post by Jellicle » Mon Jan 13, 2014 3:53 am

It sounds like you are wanting to account for different device screen sizes? If so just test for the device - if it's an iPhone 4(s) lay out your objects for a 640 x 960 screen, iPhone 5s(s) use 640 x 1136 etc.

Gerry
14" MacBook Pro
Former LiveCode developer.
Now recovering.

jacque
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 7389
Joined: Sat Apr 08, 2006 8:31 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by jacque » Mon Jan 13, 2014 7:49 pm

donbrae wrote:When, in the iOS Simulator, I'm on card 1 and I read the width of card 2, the value I get back is whatever the width of card 2 was in the IDE. However, if I read the width of card 2 when card 2 has opened, it matches the width of the device. Is that what's supposed to happen?
Interesting, I've never tested that so it's news to me. That's a nice bit of trivia to know. In practice it doesn't matter though, because as you say, as soon as the card opens it will be the size you expect. That means you can place your objects where they will belong at any time, and when the card finally does report the correct device dimensions the objects will be arranged correctly.

That's assuming you don't use the auto-sizing we now have. If you do, then you don't need to lay out anything at all which is definitely easier if it fits your project scheme.
Jacqueline Landman Gay | jacque at hyperactivesw dot com
HyperActive Software | http://www.hyperactivesw.com

donbrae
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 19
Joined: Sun Feb 22, 2009 9:49 pm
Contact:

Re: Setting the dimensions of all cards to match the stack

Post by donbrae » Fri Jan 24, 2014 8:56 pm

jacque wrote:Interesting, I've never tested that so it's news to me. That's a nice bit of trivia to know. In practice it doesn't matter though, because as you say, as soon as the card opens it will be the size you expect. That means you can place your objects where they will belong at any time, and when the card finally does report the correct device dimensions the objects will be arranged correctly.

That's assuming you don't use the auto-sizing we now have. If you do, then you don't need to lay out anything at all which is definitely easier if it fits your project scheme.
Thank you for your advice, Jacqueline. I started using the auto-sizing feature and it's working really nicely.
Jamie Smith
Composer, web dev, LiveCoder
www.donbrae.co.uk - Donbrae Studios: Music for games, film, TV, web
jamieonkeys.tumblr.com - My game development blog

Post Reply