Creating a Coloring book in AGS?

Started by Dervish, Sun 12/04/2009 07:43:21

Previous topic - Next topic

Dervish

#20
Here is the global code for Tiniting the different objects

Code:
function on_mouse_click(MouseButton button) {
 // called when a mouse button is clicked. button is either LEFT or RIGHT
 if (IsGamePaused() == 1) {
   // Game is paused, so do nothing (ie. don't allow mouse click)
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeBlue)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(0, 0, 255, 80, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeGreen)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(0, 255, 0, 80, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeOrange)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(255, 144, 0, 80, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModePurple)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(119, 0, 202, 80, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeRed)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(255, 0, 0, 80, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeYellow)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(255, 242, 0, 80, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeWhite)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(255, 255, 255, 100, 100);
 }
else if ((button == eMouseLeft) && (mouse.Mode == eModeBlack)) {
 Object* tintobject = Object.GetAtScreenXY(mouse.x, mouse.y);
   if (tintobject != null) tintobject.Tint(1, 1, 1, 100, 100);
 }
else if (button == eMouseLeft) {
  ProcessClick(mouse.x, mouse.y, mouse.Mode);
}

else if (button == eMouseRight || button == eMouseWheelSouth){
   // right-click our mouse-wheel down, so cycle cursor
   mouse.SelectNextMode();
 }
 else if (button == eMouseMiddle) {
   // Middle-button-click, default make character walk to clicked area (a little shortcut)
   // Could have been just "player.Walk(mouse.x,mouse.y)", but it's best to
   // leave our options open - what if you have a special script triggered
   // on "walking" mode?
   ProcessClick(mouse.x, mouse.y, eModeWalkto);
 }
 else if (button == eMouseWheelNorth) {
   // Mouse-wheel up, cycle cursors
   // If mode isn't WALK, set the previous mode (notice usage of numbers instead
   // of eNums, when it suits us)...
   if (mouse.Mode>0) mouse.Mode=mouse.Mode-1;
   else
   {
     // ...but if it is WALK mode...
     if (player.ActiveInventory!=null)
     {
       //...and the player has a selected inventory item, set mouse mode to UseInv.
       mouse.Mode=eModeUseinv;
     }
     else
     {
       // If they don't, however, just set it to mode TALK (change this line if you add more cursor modes)
       mouse.Mode=eModeTalkto;
     }
   }
 }
}

The problem is I want to be able to have different things happen when I paint the objects (in other words if I painted the sky purple it would change into more of a night sky.) I want to do these things in room script  but it seems that something is happening in the global script becuase any interactions I put in the room script are not done.

RickJ

I don't think there is an on_mouse_click() event handler in room scripts.  You could use CallRoomScript(button) to pass the button id to the room script's on_call() event handler if you wanted to do this in a room script.

Gilbert

Quote from: RickJ on Tue 13/10/2009 05:13:22
I don't think there is an on_mouse_click() event handler in room scripts. 

There is, from the manual:
Quote
The on_key_press and on_mouse_click events can also be handled by individual room scripts. If you add their function definitions to your room script in a similar way to how they are in the global script, the room script can intercept the keypress/mouseclick first, and then decide whether to pass it on to the global script or not. See the ClaimEvent function for more.



SMF spam blocked by CleanTalk