Author Topic: Question about creating a button script  (Read 3282 times)

kaboekieman

  • Jr. Member
  • **
  • Posts: 55
Question about creating a button script
« on: June 12, 2012, 09:33:13 AM »
Hi Malkom and the rest who is reading this,
I have a question.... currently I'm writing the menu for my interactive book. I have already made a save status procedure that writes the card number (last visited) to a text file (integer). I have a question about this. Is it possible in HAC to make a custom script to manually add 1 button or manually add 2 buttons to the home screen depending on the status of this save file?

In the txt file new users will have saved a '0', users with already a progess will have saved a '1' or '5' or '36', etc. depending on the card (page) last visited.

I have included two pictures that will show how the home card (menu) will look like. I know it is possible to make 2 cards (one for new users and one for users who already played the game) but I was wondering if it was possible to accomplisch this via only the home card and writing a custom script?

translation of the two pictures: start avontuur (starting new adventure), nieuw (new), verder (continue)

I hope someone can help me out? thx a lot in advance, Jeroen Wolf (from Amsterdam, teh netherlands)




Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: Question about creating a button script
« Reply #1 on: June 12, 2012, 12:46:28 PM »
Hi Jeroen

HAC doesn't have the ability to create new controls at runtime. However, its possible to create the extra buttons(controls) you need at design time and set them to invisble. Then when they are needed at runtime just set them to visible. Buttons can also be resized and move into position at runtime.

The relevant commands are ButtonSetView, ButtonSetMode.
Also, ButtonSetLeft, ButtonSetTop, ButtonSetWidth, ButtonSetHeight.

To set a control as invisble at design time - use the Visible checkbox on the Place tab of the Properties toolbar.

The demo project PreSchool Sums hides most of its canvases at design time and then makes them visible during runtime.

Your graphics look really great :)

Malkom

 
I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

kaboekieman

  • Jr. Member
  • **
  • Posts: 55
Re: Question about creating a button script
« Reply #2 on: June 13, 2012, 07:42:41 AM »
thx Malkom... and a great idea :) I've looked into the help file of HAC (really usefull) and found the commands you said in your reply. That should work ;) I have another question. For my book I use a lot of png's and backgrounds. What do you advise: To load a background image via this command (at the StartUp of the MainCode) and for every orther card in my application:

Local menu
Put 'Afbeeldingen:menu.png' into menu
CardLoadImage(1,menu,1)

or to use the image bank (via a canvas)?

I know HAC can work with both, but I'm interested what will be the best method (least in-game loading time). Every card (page) will have a full size (600x1024) background image with three control bottons (png images).

thx a lot ... Jeroen

Malkom

  • Administrator
  • Sr. Member
  • *****
  • Posts: 287
Re: Question about creating a button script
« Reply #3 on: June 13, 2012, 08:34:00 PM »
Hi Jeroen

The simplest method is just to load the images during startup as that would give the fastest loading time for each card although the home card's first appearance would be delayed a bit.

One thing to consider:- if your book is running on an older device then it might not have much free RAM for simultaneously holding lots if images. Supposedly older devices were limited to 16MB per app with new devices allowing 48MB per app, perhaps more modern tablets allow even more. 
Trying to find out how much RAM an app is actually using is not so easy. We use an app called SystemPanel by NextApp Inc and it gives very interesting results:- our Solar System demo appears to use 17MB of RAM on a tablet with 800x600 screen. Your 600x1024 images would each need about 2.5MB so you can get a rough idea of how much RAM is needed.
Anyhow, if you need to free an image from memory the CardRemoveImage command can do that.

By the way, if possible, I usually try to go for simplicity first and then only optimise things if needed  :)

Malkom


I am sorry but I do not have time to answer questions by PM or email.
If you post your questions in this forum then it might help others.

kaboekieman

  • Jr. Member
  • **
  • Posts: 55
Re: Question about creating a button script
« Reply #4 on: June 15, 2012, 10:49:27 AM »
o.k. Malkom... I will try your approach... thx for the update about the memory usage... I think I will try to to make only a few card (thus limiting the loading/memory for all the art) and making them templates, with a sort of database (flatfile) structure for all the different pages (just like you did on the solar app). Thanks for all your help  8)