How to make a button vanish

AntonBrz

Member
Licensed User
Longtime User

This should be simple but I'm not sure how to do it. I'm trying to make a card game. I can make cards out of buttons by putting images on them to show the backs of cards. When the player touches the card, the image of the back of the card should vanish, ie the button disappears, and makes it seem the card is turned over. (another image). Does anyone know a way to make a button vanish? cardbutton1.Visible = False doesn't seem to work.
Also, instead should I make little "Backgrounds" and "Foregrounds" several of them, to create cards? Or one big foreground transparent layer with images of cards in a rectangle perhaps? The images of the cards have to "touchable" so they react to touch and vanish. How would you do it? :sign0163:
 

JonPM

Well-Known Member
Licensed User
Longtime User
cardbutton1.Visible = False should work. Where are you calling this? It should be called in the cardbutton1_Click sub. Can you show more code?
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Button to vanish


I didn't include a code because I made several test attempts (kept separate in different sub directories inside my B4A folder which is right on the C: drive) all of which compile without errors, but none made the button vanish. The buttons are declared correctly, show no errors in compiling, have the images I wish and when the test opens up on the emulator or my Android tablet clicking the button changes the color of the button, but although I included CardButton1.visible = False it didn't work. I"ll try it your way, calling it transparent? I want to make it vanish completely, so I could have a hidden button beneath which in turn could then be clicked to take me to yet another subroutine. I'll put together some simple code for a view with a card button and post it. I was working on that when your fast reply came. I'll be back in a few hours with code.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User

Thank you for you help. Hey it works now, beautifully displays a card image on a green tabletop, although I could also use a table image for the table. The good thing something is right so the card/button vanishes now when I click on it. I've yet to try putting another button exactly below the first. Do you have a quick delay code I could add to the sub to keep the first button touch from triggering the second button (card) beneath?

My simple working code for a card example:



#Region Project Attributes
#ApplicationLabel: Card Example
#VersionCode: 1
#VersionName:
'SupportedOrientations possible values: unspecified, landscape or portrait.
#SupportedOrientations: unspecified
#CanInstallToExternalStorage: False
#End Region

#Region Activity Attributes
#FullScreen: False
#IncludeTitle: True
#End Region

Sub Process_Globals
'These global variables will be declared once when the application starts.
'These variables can be accessed from all modules.

End Sub

Sub Globals
'These global variables will be redeclared each time the activity is created.
'These variables can only be accessed from this module.
Dim Card_Tabletop As Panel
Dim card1 As Button
Dim Tabletop As Panel
End Sub

Sub Activity_Create(FirstTime As Boolean)

Activity.LoadLayout("Card_tabletop")
card1.SetBackgroundImage(LoadBitmap(File.DirAssets,"card.jpg"))
End Sub

Sub Activity_Resume

End Sub

Sub Activity_Pause (UserClosed As Boolean)

End Sub

Sub card1action_Click
card1.Visible = False
End Sub
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
when you leave a message with code, click on the pound sign. then in between the code text that pops up, paste your code. It is especially designed to display code. Always try to give code so that experts (which I am not) can look at and quickly give a response.
 
Upvote 0

wheretheidivides

Active Member
Licensed User
Longtime User
put your images in imageviews. and put the imageviews on a panel. That way you can turn the panel on or off and everything it as well.

forget the background image. Put it in an imageview on a panel. Then you can do effects like slide the panels on and off the screen.

don't use the button for images. Use the buttons for commands like 'hit' 'stay' and then you can control the imageview with
IV1.enable = false
IV1.visiible = false

IV2.enable = true
IV2.enable = true.

If you want, you can have use the card like

sub IV1_click
'do something when you click this card
end sub


I did a game on the goggle play store called 'low-joe'. It is a casino based card game you can look at for ideas. Currently on in the USA for download.
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Re Low-Joe: Putting an image veiw on a panel for cards

This is directed to the author of Low-Jo. I want to try the imageview on top of panel method. The example which seems to use this is the horse running over a background of Montana in the LAYERS program source code. I spent all day trying to cut and past that code to produce just a table and a single card image on top, but the LAYERS source code is very complex, addressing sizing and motion, and a data base with animated images of the horse facing two different directions. If I could just find a tutorial which shows the essential dims and initializing necessary to set up one background panel, one overlaying transparent canvas and on image in a rectangle that sits on the transparent canvas, if I could get some clear explanation of setting up those three things, I could get started and use the principles over and over. I know how to set up a panel of course. What about the transparent layer over it, and the imageview on top of it? What tutorial explains the rectangle with an image view in it? I'd like to see a source code which is like a simplified version of the layers program, which just sets up the rect on an over laying canvas. Thank you in advance for any help. .
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
More on canvas

I think I have some confusion about 'canvas'. Is it a real reserved word, used in some library? Do I need a library besides core to use it? Is there another source code example that uses canvas I can study besides LAYERS?

Thanks
 
Upvote 0

AntonBrz

Member
Licensed User
Longtime User
Thank you

Thank You Klause,

I'm honored and humble that such a senior member took the time to respond to my question. I'll read the chapter you indicated in depth.
For my card game, I don't see why I need a transparent layer above the table at all. If I put an image view on top of the background table panel, it displays a card perfectly well. I just hope the chapter you directed me to will explain all the possible commands (members?) for changing the position and angle of an image view so I can move it around the screen in a kind of animation.
 
Upvote 0
Top