Loading images from tables dynamically
I know this has been addressed in many ways by many others, but I have not found the answer I am looking for.
I am creating an interactive in gamesalad. I have a menu system on the left that changes scenes and sub menus that load images into the selected scene. The loading of the images is coming from a table, only the images are not loading unless I click on the scene button again.
The table data is being copied into a generic table, as suggested by others here as a work around to not being able to dynamically call a table name.
The set up uses one actor and multiple instances of said actor, so the code resides only in the prototype.
I can see that the data is being copied as I have a display text attribute that shows up with the image, and it displays exactly what it should.
hope this gives enough info to help me get these images to show up on the click of the sub-menu without having to click onthe scene to load them.
thank you in advance.
Comments
Can you post a video of what's going on, and a commentary on what you want to happen?
Mathtap.com (Android) | Fridgemanager.com (Android) | Breakoutofspace.com (Android)
What does your rule look like for loading the images and what does your rule look like for clicking on the scene button?
And what does your table data look like?
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
Pressing Sub-Menu Button:
Variables:
SubCongNum = number assigned to each of the 9 sub menu buttons.
Rule
touch pressed
set (game.subConfigNum) to (self.name)
change attribute
set (self.name) to tableCellValue((game.tbl_sub, (self.name),2)
Rule:
There are 9 of these for each Sub-Menu item, each sub-Menu has its own series of selectable images that appear in a column to the right of the menu buttons. Each series of images loads from a table specific to that sub-menu item.
touch pressed
if (game.subConfigNum) = 1
do:
Copy table: tble_DS_TraditionalMenu to tbl_Generic
Rule:
This rule toggles the image of the button to selected or not
do:
if (game.layerControl) is true
change attribute
set (game.SubConfigMenu) to (self.name)
set (self.image) to (tableCellValue(game.tbl_sub),(self.name),3))
else:
rule
if (game.SubConfigMenu) !=(self.name)
do:
change attribute
set (self.image) to (tableCellValue(game.tbl_sub),(self.name),2))
Actor for loading images.
these actors are placed into alignment to be used in a scrolling library. i'm omitting some of the code from this as its not relevant.
Variable:
DS_ConfigNum = number set to each image (actor box) to call from later, this also sets a new image on screen to the right of this scrolling library.
change attribute
set (self.image) to (tableCellValue(game.tbl_generic),(self.name),2))
Rule
touch is pressed
set (game.DS_ConfigNum) to (self.name)
The Main menu button simply changes its image if pressed and goes to a specific scene.
tables:
column 1 | column 2
1 | 001.png |
2 | 002.png |
3 | 003.png |
4 | 004.png |
what should happen is that:
you click a sub-menu item and it loads images related to that topic into the scrollable library. it all works fine with the exception that the scene has to be reloaded for the images to actually appear. i know its working as the display text pulling from the same tables is showing accurately (without reloading the scene).
thank you all.
this is my first project and I am in very deep.
Yes! So first of all, bravo for taking on something rather difficult.
I'll be honest that it's a bit hard for me to follow all of this without the benefit of the project folder itself. I generally understand what you're trying to do but some of the logic escapes me.
One thing I noticed is that you are changing self.Image to the second or third column value as in this behavior:
When you probably should be constraining self.Image to that expression value.
When you have a rule that says If [condition is true] do change attribute, that rule will only trigger when the condition value changes from false to true. If the condition is true, it will trigger once and if the condition is still true, it won't trigger again. So constraining the value might resolve that. Or possibly taking the change attribute behavior out of the rule entirely and making it a constrain behavior might do the trick though I'm not sure that's correct for the rules you have (again, I'm a tad lost).
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User
tatiang, thank you.
constraining the attribute worked beautifully!
i would love to send you the project so you could give it a once over to help me learn more if your willing. cant post it here though. any suggestions on getting you the project.
So constraining the attribute for the image boxes worked perfectly, but I also tried it for the buttons as you mentioned above and they no longer work.
Essentially the buttons are an on/off button, when clicked they are one image, when another button is clicked they turn back to their original image.
So I guess in this particular scenario they should be change attributes.
You're welcome!
I'll send you a private message (PM) about this.
If you want to post the project folder here or send it as a private message, you'll need to .zip it first, upload it to a file-sharing site, and then post/send the download link.
New to GameSalad? (FAQs) | Tutorials | Templates | Greenleaf Games | Educator & Certified GameSalad User