I am trying to use GetObjectAt(x,y)... But it just doesn't work, i tried with object based (2.7) command too.
Like this:
if (GetObjectAt(93,37)==1) cJack.Say("blabla");
or.
if (Object.GetAtScreenXY(93,37) == oPIC1) cJack.Say("xdalkhjd");
I puted the code on the hotspot -> interaction click code (so if you click on hotspot and object is in those coordinates Jack should say the lines..) but it doesn't.
I even tried to put the code to "Enter room for the first time" script, but it still doesn't work.
Object is set on those coordinates, i checked in the editor, and later even used move command for object to 93,37 co. but it still doesn't work.
Using ags 2.7...
Now i used o"objectname".x == 93 and o"objectname".y == 37 and it works fine .
And another questing, how can you define multiple objects in one line ?
like: 0bject[from 3 to 7].X ==93.... ???
so that the code would look if object 3,4,5,6,7 are on x==93 .
Use a "while" statement.
int counter=0;
while (counter<=7) {
object[counter].DoWhatever();
counter++;
}
Thanks Brisby..
I hoped there is simpler solution, like if you are using old scripting you can write (GetObjectAt(x,y)>=0) and it gets all object, with no extra writing..
So any idea why GetObjectAt(x,y) doesn't work (first post )..?
Is the object transparent at its bottom-left corner?
I think if "Pixel-perfect click detection" is enabled in the General settings, only opaque parts of the object graphic return the object.
Object it full square (has no transparent areas). I don't know why object.X== and object.Y == ; works fine than ? What is the different between if (GetObjectAt(93,37)==1) cJack.Say("blabla"); and object.x== .... than ?
Try using
Display("%d", GetLocationType(93, 37)); or Display("%d", GetObjectAt(93, 37));
Maybe it'll help.
(And keep in mind that GetObjectAt() uses screen-coordinates.)
Actually i wanted to get object position to move some puzzle piece around, and they get blocked if object is detected nearby, my room is not scrollable. I made it work with object.X==. and object.Y==, but i still wonder why GetObjectAt doesn't work..
Have you tested to see that the object being returned is the same as oPIC1? It would appear that it's not, but you could test it with something like:
Object* objat = Object.GetAtScreenXY(93, 37);
string objatstr;
string pic1str;
if (objat != null) objat.GetName(objatstr);
else StrCopy(objatstr, "NULL");
oPIC1.GetName(pic1str);
if (!StrComp(pic1str, "")) StrCopy(pic1str, "NULL");
Display("Object.GetAtScreenXY(93, 37) = %s. oPIC1 = %s.", objatstr, pic1str);
Which will display the name of the object the mouse is over and the name of oPIC1 (displaying "NULL" if they are left blank). I hope you get the problem resolved.
Quote from: Sektor 13 on Sun 21/08/2005 17:35:28
I made it work with object.X==. and object.Y==, but i still wonder why GetObjectAt doesn't work..
The object.X and object.Y are the co-ordinates of the bottom-left corner of the object.
GetObjectAt checks whether there is a non-transparent pixel belonging to the object at those co-ordinates.
They are totally different checks, which is why they can return different results.
still, my object is not transparent, but i used objects bottom-left coordinates as X an Y...
Did you mean, the bottom left pixel of your object is not transparent?
I think he's saying none of it is transparent. Or at least not the pixel at (93, 37). Which would explain the confusion as to the results...
Quote from: Sektor 13 on Sun 21/08/2005 16:18:24
Object it full square (has no transparent areas).
Try to check for (93, 36) and see if it works, maybe sometimes the object pivot was set a line lower than the actual displayed sprite (I'm not quite sure about it though).
ok, i have done some testing.
I tried coordinates in the middle of my object and it works !
So I went further.
--------------------
**edited** i deleted some of the text, as it was wrong**
--deleted text--
**end of edit**
---------------------
I used Object.GetObjectAtXY(...)==object)... on all far points of my object. And i found out that GetObjectAtXY detects my object at MAX X = from 75 to 83 AND Y from 28 to 36 This means that GetObjectATXY has offset for Y -1 and it is correct for X.
???
AGS probably takes your Y position, subtracts the sprite height, and draws the sprite.
So for your example:
y = 37
h = 9
Draw at y-h = 37-9 = 28
Then it fills pixel rows 28-36.
Confusing, but predictable.
Might be dangerous to fix.
Probably needs a note in the manual.
Got it in one, Steve.
Yes, this is slightly confusing but I daren't fix it because there are too many games relying on the current system for lining up graphics and so on.
I'll add a note to the manual to make sure people are aware of it.
Edit by strazer:
Beta 5 has a note for the Object.Y property.
--
(Irrelevant messages removed to unbump thread.)