Hollywood has from a programming point of view two different approaches to how it handles brushes.
The first approach is that you have to draw all the graphics to screen each cycle. That basically when cycle starts, the screen is black, and if you don't draw anything, it also will stay black. That regardless how much graphics you drew last cycle, there will be nothing at start of next cycle.
The second approach is the LAYER approach. In this case, graphics are like real-life stickers on a table. You have a sticker, and you can place it on your table and it stays there until someone moves it around or removes it. on the LAYER approach this is how brushes work too. You once tell you are placing a brush at location x, y, and it will stay there until you move or remove it.
Both approaches have their pros and cons, but in your case I recommend using the second, the LAYER approach, since it is easier for a beginner and you don't need to take care of so many things.
To explain this from code point of view, the first approach would basically make following changes to your code:
This
would change into something like this:
Code: Select all
Function UpDateGraphics()
if MyFirstBrushOn = true then DisplayBrush(1, x, y)
if MySecondBrushOn = true then DisplayBrush(2, x, y)
endfunction
Repeat
UpDateGraphics()
WaitEvent
Forever
Notice that this example isn't a working version, since there are things that need to be taken care of before this would work, I am just explaining the principle here.
On your "OnMouseOver" and "OnMouseClick" functions, you would do something like this:
This
Code: Select all
Switch msg.action
Case "OnMouseOver":
PlaySample(1)
Case "OnMouseDown":
PlaySample(2)
Stage = 1 ; Updating this variable here doesn't work, why?
EndSwitch
would change into this:
Code: Select all
Switch msg.action
Case "OnMouseOver":
PlaySample(1)
MyFirstBrushOn = True
Case "OnMouseDown":
PlaySample(2)
Stage = 1 ; Updating this variable here doesn't work, why?
MyFirstBrushOn = False
EndSwitch
idea is that Your Repeat-Forever loop would continuously keep repeating "UpDateGraphics()" function each cycle, which would keep checking what is the state of MyFirstBrushOn and MySecondBrushOn and depending if they are TRUE or not, would depend if they would be drawn to the screen.
When mouse moves to OnMouseOver, it would change MyFirstBrushOn into TRUE, and after that that DisplayBrush(1, x, y) would be executed each cycle, resulting in it looking like there is stable graphic image on screen.
When MouseClick would change MyFirstBrushOn to FALSE, this "UpDateGraphics()" function would stop executing DisplayBrush(1, x, y) command each cycle, resulting it seeming like it is disappearing, since it is simply not drawn anymore.
Now the LAYER approach is simpler in its approach, and the example code I am going to show, is basically a working one.
This code will stay as it is already, since when using LAYERs, Hollywood takes care of drawing brush every cycle (or you could say, frame)
But this:
Code: Select all
Switch msg.action
Case "OnMouseOver":
PlaySample(1)
Case "OnMouseDown":
PlaySample(2)
Stage = 1 ; Updating this variable here doesn't work, why?
EndSwitch
Would change into:
Code: Select all
Switch msg.action
Case "OnMouseOver":
PlaySample(1)
ShowLayer(1)
Case "OnMouseDown":
PlaySample(2)
HideLayer(1)
Stage = 1 ; Updating this variable here doesn't work, why?
EndSwitch
And you are almost done. For there are two things you still need to do, but to explain, idea is that you have a LAYER with ID 1 that you wish to show/hide.
After you have placed it somewhere (which we will do next), after that you can simply tell that you wish to either show layer id 1, or hide layer id 1, and it will happen.
To make this work, you need to add basically two lines to beginning of your main code:
To this:
Code: Select all
;*** MAIN LOOP ***
;-----------------
If Stage = 0
p_MainMenu
ElseIf Stage = 1
p_Stage01
Else
End
EndIf
EscapeQuit(True)
Repeat
WaitEvent
Forever
You will add TWO lines to beginning, changing it into this:
Code: Select all
;*** MAIN LOOP ***
;-----------------
EnableLayers()
InsertLayer(1, #BRUSH, 2, x, y, true)
If Stage = 0
p_MainMenu
ElseIf Stage = 1
p_Stage01
Else
End
EndIf
EscapeQuit(True)
Repeat
WaitEvent
Forever
EnableLayers() means that from now on you can use those layers. If you try to use command "InsertLayer" before first doing
EnableLayers(), Hollywood will complain that Layers are not on.
The InsertLayer command is a bit more complicated.
First of all, when using LAYERS, every type of graphic, that is video, Brush, Anim, TextObject, are all considered as same type - a Layer.
This means that instead of using different commands to display them, like DisplayBrush or TextOut, you will simply be using LAYER commands to do their stuff.
Notice however that you can still keep using, for example, TextOut command, even Layers are turned on.
Just that understand that Layer can be Brush, text, video, anim - anyone of those, and when you use ShowLayer(n), it might result in brush, video, anim or text being shown, depending what LAYER id n happens to be containing.
When using InsertLayer command, the you first tell which ID number it will take. In that example case I decided to use ID spot 1, it however could be any other number as well, like 20.
next I am using #BRUSH, this will tell Hollywood that this Layer is actually a brush, instead of Anim, Video, or TextObject.
and after that comes another number, in this case I am using number 2. This means that it will Load Brush ID number 2 to be used as the brush.
Point being that you first need to create a brush ID 2, for example by using LoadBrush(2, "filename"), for if Brush ID 2 doesn't exist, then InsertLayer cant use it.
Then I tell its x and y co-ordinates on the screen, and last option is true/false. If I use TRUE, it means that Layer will start on hidden state. using FALSE would display that layer instantly.
After this I can simply use, ShowLayer(1), and it will start displaying this Brush I used to put to that Layer ID 1 using the InsertLayer command in the co-ordinates I set when using InsertItem.
And there you go, now this program works.
Well almost. Since naturally you do need to create that Brush id 2 first. One way would be to use:
@BRUSH 1, "MenuTitle.jpg"
similarly how you are now using
@BGPIC