Object still not reponding to mouse click Solved.

Started by cinos, Tue 10/10/2006 13:27:17

Previous topic - Next topic

cinos

An object I have got moving across the screen is not responding to a mouse click. The mouse cursor is a watch when it is moving. I want the object, when clicked to place an item in the inventory. Any ideas.

function on_call(int value){
Ã,  if(value == 1) {
Ã,  String answer = txtUserInput.Text;
Ã,  gTableanswer.Visible = false;
Ã, 
Ã,  // This is the code to check it the heartstone is activated!(Thrown 1 is the object that
// calls the Heartstone)
Ã,  if((answer.AsInt == Product)&&(Thrown==1)){
Ã,  object[Thrown].Visible = false;
Ã,  GiveScore(5);
Ã,  PlaySound(3);
Ã,  object[0].Animate(1,6,eOnce,eNoBlock);//The skeleton burns and the HEARTSTONE1 appears and moves
//across the screen. I want the player to click it before it disappears to place in the inventory.
//I have set the oject interaction to on any click. When the script runs there is a watch on the screen
//and the object does not respond to the mouse.
Ã,  Wait(40);
Ã,  oHeartstone1.Visible=true;oHeartstone1.Move(150, 200, 2, eNoBlock, eAnywhere);oHeartstone1.SetView(5);
Ã,  oHeartstone1.Animate(0, 1, eRepeat, eNoBlock, eForwards);
Ã,  object[0].Visible=false;
Ã,  object[0].SetPosition(337, 269);
Ã,  PlaySound(1);
Ã,  Wait(200);
Ã,  oHeartstone1.Visible=false;
Ã,  PlaySound(4);
Ã,  object[0].Visible = true;
Ã,  object[0].SetView(3);
Ã,  object[0].Animate(2,6,eOnce,eBlock);
Ã,  object[0].Animate(0,6,eOnce,eNoBlock);
Ã,  object[0].Move(280,266,1,eBlock,eWalkableAreas);

I now have this code and have placed it in the room script at the top before any regions.
function repeatedly_execute_always(){if (Mouse.IsButtonDown(eMouseLeft)&&Ã, 
Ã,  Ã,  (oHeartstone1.Visible)==1)
Ã,  Ã,  player.AddInventory(inventory[3]);
Ã,  Ã,  oHeartstone1.Visible=false;}
Ã,  }

Problem is now the heartstone1 does not appear at all and does not go into inventory! I use the wait command to time the appearance of objects with other animations.Ã,  I think this should remove the heartstone1 (If it worked!) but how do you code get it to actually be over the moving object like, if mouse down over object heart tone1 then......???

SSH

Quote from: cinos on Tue 10/10/2006 13:27:17
An object I have got moving across the screen is not responding to a mouse click. The mouse cursor is a watch when it is moving. I want the object, when clicked to place an item in the inventory. Any ideas.

//The skeleton burns and the HEARTSTONE1 appears and moves
//across the screen. I want the player to click it before it disappears to place in the inventory.
//I have set the oject interaction to on any click. When the script runs there is a watch on the screen
//and the object does not respond to the mouse.
  Wait(40);
  oHeartstone1.Visible=true;oHeartstone1.Move(150, 200, 2, eNoBlock, eAnywhere);oHeartstone1.SetView(5);


Those Waits in your script are what are making the game "block" and thus be unresponsive to clicks. You can get around this two ways:

1. Don't use wait, but rather set a timer and use the repeatedly_execute function to check it each game cycle
2. Use repeatedly_execute_always tocheck if the mosue button is pressed and if the cursor is over the object
12

cinos

#2
I thought this might be the case but being a newbie was not sure. I have added a repeatable_execute_always() but this deletes the heartstone1 altogether and does not place it in the inventory. Check the script above. Also how do I make the mouse click return a yes over a moving object? (I hope this makes sense!)

SMF spam blocked by CleanTalk