Changing character view when mouse rolls over them (SOLVED)

Started by Smoke, Tue 12/09/2006 05:17:07

Previous topic - Next topic

Smoke

I kind of have this idea of having the look cursor act as a sort of magnifying glass, whereby when the mouse moves over objects and characters you get a more detailed view of things. I'm pretty sure I can use regions for objects and such but I'm not sure how I would do this for characters. I've thought maybe using the same system as in the GUIs that display a character's name somewhere when the mouse rolls over them would work, except replacing the display-character-name with change-view-to-x....or something. I'm really not sure.

SSH

Well... in your repeatedly_execute:

Code: ags

if (mouse.Mode==eModeLookat) {
  if (Character.GetAtScreenXY(mouse.x, mouse.y)==cSomeone) {
    cSomeone.LockView(ZOOMVIEW);
  } else {
    cSomeone.UnLockView();
  }
}


but I have a feeling it will be more complicated than that...
12

Smoke

Nope, that works brilliantly thank you :). It flashes between the two views when the mouse is right on the edge of the character, but I can live with that. Thank you, that seems so simple.

Ashen

That might get a bit cumbersome with multiple characters, though. Since I already had typed up, how about (untested):
Code: ags

//Top of Global Script
Character *ZoomChar;

// in rep_ex
if (mouse.Mode == eModeLookat) {
  if (Character.GetAtScreenXY(mouse.x, mouse.y) != null) {
    if (ZoomChar == null) {
      ZoomChar = Character.GetAtScreenXY(mouse.x, mouse.y);
      ZoomChar.LockView (ZOOMVIEW);
    }
  }
  else if (ZoomChar != null) {
    ZoomChar.UnLockView();
    ZoomChar = null;
  }
}


And something similar for Objects. You could use Custom Properties to store the ZOOMVIEW variable (as well as the Normal graphic/view for Objects).
I know what you're thinking ... Don't think that.

Smoke

Hmm well that works too. I'm just not sure I understand how to use the Custom Properties to change the view for seperate characters...

Ashen

Rather than using:
ZoomChar.LockView(ZOOMVIEW);

Use:
ZoomChar.LockView(ZoomChar.GetProperty("ZoomView"));

Where 'ZoomView' is your property, holding the zoomed view (obviously) for the character.
I know what you're thinking ... Don't think that.

Smoke

Yep, ok that makes sense. One more question though. How do I actually make the property hold the character's zoom view? I'm not sure I fully understand these property things...

Ashen

I'm not sure where you could be having a problem as it's fairly self-explanatory, but step-by-step:

1. Go to the Character Editor window (for characters, or the Object EDitor for objects, etc).
2. Click the 'Properties' button. If you don't have any properties set up, you'll be asked if you want to go to the Schema Editor. Click 'Yes'. If you DO have some properties already, click the 'Edit schema' button to be able to create new ones.
3. Right-click the Properties list, and select 'Add new property'. Enter the details (Name, Description, Type and Default Value) for your new property. (In this case, the 'Default Value' doesn't really matter, since there'll probably be a different value for every Character/Object.)
4. OK the new property, add any others you want and Close the Schema window.
5. You should now have the Properties window for the selected Character/Object/Whatever (e.g. for Roger, it'll say 'Properties - Character 0'). Change the Default Values to whatever you want them to be in this case. OK it, and move on to the next Character/Object/Whatever.
I know what you're thinking ... Don't think that.

Smoke

Heh, ok I've got it now. I understood how to make a new property and all that, I just didn't understand that I had to set the number of the property to the number of the view I want. I didn't understand quite how the property was supposed to be holding the view, but luckily I figured it out. Thanks very much for your help :).

SMF spam blocked by CleanTalk