There is a Big mistake in my Code. But i dont find it! Can somebody help me?
For understanding: i want These Dialogs to appear when i Touch the House or the Shop. When i Touch the House i want the left Dialog and the Guy-Icon to appear, and when i Touch the Shop i want the right Dialog and the Shop-Icon to appear. When i Touch the already-touched-Building i want the Dialog to dissappear. Its that simple, but i Cant manage it -.-
Here is the Code: http://maxiking16.posterous.com/upgrade-pro
In your touch loop HOUSEisItRight is getting set to true and then false with the same touch
Using elseif is a way to get only one condition executed at a time
Just taking a quick look…
First, the touched() function never gets called. The only function that gets called on each cycle is draw(), so if you want the touched function to get called, you have to include a call to it there.
Second, within the touched function, you’ve used the variable touch, but you haven’t passed anything to it.
To get around these issues, add this line to the bottom of your draw function.
Next, there’s nothing to call the dialog functions. If you touch one of the houses, it does change the variables, but doesn’t call the other functions. The code has to be told to call that function.
So, for example, go in after the line and add a call to draw the dialogs, like this:
HOUSEisItRight = true
In general, that’s what is missing: the calls that tell it to actually perform a function.
So does anyone else have the “flashing color” issue where when you strat a program the background will flash like a strobe and nothing will run? You have to hit reset a bunch in order for it to stop.
I remember having that and forget precisely what I did. I think a combination of rect(0,0,10,10) and background(0,0,0) at the start of draw() should fix. I think after 1.2.6 the rect won’t be needed.
@Ldsguy1 the flashing shouldn’t happen any more with 1.2.5. Are you using the latest version?
Though I am using old code.
@mark: wow, its better than before. But it does what i expected: it only shows my upgradewindows if touch.state == began, and when i put my Finger off or move it, the Color is changed to HOUSE-/STOREDIALOGf(alse)t(ouch)c(olor), wich means the Window is Not kept open for further instructions…
The moving issue can be changed by adding: or Touch.state == moving, but the Otter One? I tried to use “touch” instead of “currenttouch”, but then it says its not existing… Any idea?
@ipda: ok, sounds Logic. I’ll change it. But how? Can you just give an example?
i ment @Mark and @Ipda41001
If began then
If not store then
Elseif store then
This isn’t exactly your code but the if structure is what I’m attempting to show.
Doesnt work to… I thought "Touch.state == ended would solve it but Look…
(the 0.1 is the One with your if-idea)
The dialog goes away because it’s not being drawn in the draw() function.
Remember, draw gets called every cycle (several times a second).soyou are drawing your dialog, and then draw immediately comes along and erases it.
The secret is to draw the dialog from the draw() function, and use a state variable to indicate whether or not it should be drawn().
Wow your right! Ill try it
Doesnt work either… I took the isItRight as a statevariable, but now no dialog is drawn…
Hhh… Thinking about giving up… I think i should try something that is much easier, i cant always ask you poor guys.
See if this looks more like what you had in mind. I added a little variable to track dialog state. I also commented out your tint statements in the dialog. It looks like everything was getting tinted with alpha=0, making it invisible.
Omg thank you so much! I optimized your changes, and now, thats what i looked for! Thats what was thinkin of! Now, im going to work on further versions
Oh try this One, i added ability to upgrade the store