Hi,
I'm having a bit of brain bother at the moment.
I am looking for a way to capture (mouse clicking) on an animating button.
The player enters a room, a button is animating (flashing).
If the player clicks on the button whilst it is animating he gets ChurchHelp =1 else if the button is not animating he gets ChurchHelp =0. On both occasions he goes to Room 17 where Church function carries out the ChurchHelp check and responds accordingly and then returns to room and the animating button stops and ChurchHelp=0.
This animating button animates in further rooms until it is clicked.
There is not a check for if Button animating afaik.
What I have so far:
On Room on Load:
if(HasPlayerBeenInRoom(17)){ // Church Room already visited
Button74.NormalGraphic=710; // Church button normalgraphic
ChurchHelp =0;
}
else if(!HasPlayerBeenInRoom(17)){ // Church Room not yet visited
Button74.Animate(17, 1, 4, eRepeat); // Church button flashing
if (Button74.Animate(17, 1, 4, eRepeat))
ChurchHelp =1;
Animating Sprites, in order: 710 2997 710 2997
Can you assist me please..
cheers
Quote from: slasher on Sun 04/05/2014 17:03:08if (Button74.Animate(17, 1, 4, eRepeat))
Button.Animate does not return a value, it is the command to start the button animating. So, obviously, this won't work.
As you pointed out, there's not any type of Button.Animating property to let you know if the button is currently animating. The best option presently is just to create a separate bool variable to track it yourself. When you call Button.Animate, set the bool to true. When you stop the animation (e.g., change the NormalGraphic), set the bool to false. Then you can check if the button is animating by checking your variable.
EDIT: I copied the button normal sprite and pasted as new sprite number and used that in the animation, seems to work so far...
Hi Monkey,
I have added a Global boolean 'animating' (set to false) and set it to true if button is animating. Then in rep exec added if boolean animating is true Churchhelp=1
Room Load
if(HasPlayerBeenInRoom(17)){ // Church Room already visited
Button74.NormalGraphic=710; // Church button normalgraphic
}
else if(!HasPlayerBeenInRoom(17)){ // Church Room not yet visited
Button74.Animate(17, 1, 4, eRepeat);
animating=true; //
Rep exec
if (animating==true))
ChurchHelp =1;
should this work as it seems to be returning ChurchHelp =0?
cheers
Given how you have put it in your example, could you not just bypass the animation bool and do this?
Room Load
if(HasPlayerBeenInRoom(17)){ // Church Room already visited
Button74.NormalGraphic=710; // Church button normalgraphic
ChurchHelp = 0;
}
else if(!HasPlayerBeenInRoom(17)){ // Church Room not yet visited
Button74.Animate(17, 1, 4, eRepeat);
ChurchHelp = 1;
}
Hi Intense Degree,
Whilst I started with that code it is in fact more complicated with additional factors. Anyhow, I seem to have solved the issue, at least for now.
cheers anyway...
Glad you got it working, but I would just like to say that under no circumstances should anyone ever have:
if (condition) { }
else if (!condition) { }
That is what else means.
if (condition) { }
else { }
Is sufficient if all you are doing is checking the inverse of the original condition. You should only have else if when you are checking multiple (more than two) unique possibilities, such as the results of Random(10) or the current mouse.Mode.
Hi Monkey,
I totally agree. I only added it so i could see the whole thing better. Sounds silly but true ;)
cheers
That's what comments are for. Keep in mind that block comments can appear in-line:
if (condition) { }
else /* if (!condition) */ { }