SUGGESTION: GetLocationScriptName(int x, int y) [SOLVED]

Started by Joe, Sun 10/09/2006 13:32:12

Previous topic - Next topic

Joe

Hi every one, I was making a really nice game, but I had to stop its making because I couldnt find any way to make what i wanted.

And I was thinking about this:
Code: ags

//At rep_ex:

GetLocationScriptName(mouse.x,mouse.y).Animate(8,6,eOnce,eBlock,eForwards);

//It would make, the object or the character which has the mouse over animate


But that function didn't exist and I couldnt find a different way to do it :'(

If my suggestion is obsolete and there is another way to do this, I would be really pleased if you tell me how.

Thankyou.
Copinstar © Oficial Site

Ashen

The problem with that would be, what if there was nothing there? Or a Hotspot, or GUI?

So, since you'd have to add (at least) a check of GetLocationType(), why not just use it anyway?

Code: ags

if (GetLocationType(mouse.x, mouse.y) == eLocationCharacter) {
  Character *theChar = Character.GetAtScreenXY(mouse.x, mouse.y);
  theChar.Animate(8,6,eOnce,eBlock,eForwards);
}

else if (GetLocationType(mouse.x, mouse.y) == eLocationObject) {
  Object *theObj = Object.GetAtScreenXY(mouse.x, mouse.y);
  theObj.Animate(8,6,eOnce,eBlock,eForwards); // Assuming you've set a View for it, somewhere
  // You could have a check of 'theObj.View != 0', to ensure it DOES have a View, before animating
}


It's not quite as neat, but it should work.
I know what you're thinking ... Don't think that.

Joe

Thankyou for answering but i had tried that before and it gave me a error:
Cannot declare global instance of managed type.

EDIT- Sorry, it does work i just had forgotten the *.

Thankyou.
Copinstar © Oficial Site

Ashen

Do you remember the code you used? You'd get that error if you missed the '*' out of the declaration (i.e. Character *theChar...), so using exactly what I have should work. (In theory - not tested.)

EDIT: Gah, sorted it while I was typing. So, problem solved?
I know what you're thinking ... Don't think that.

SMF spam blocked by CleanTalk