![]() |
worldx() and worldy() - pretty slow?
The conversion from screen coordinates to woorld coordinates via worldx() and worldy() seem to happen pretty slow. For example, when I'm showing an image on the tile layer, but its supposed to look like its on the screen layer, it would lag behind if I move. This is not the case btw.
Though, it would be useful if there was some other way that wouldnt be so damn slow and laggy. To be certain, I actually need something that returns the level x and y at the edges of your screen. Any ideas? |
Ya, it definitely lags behind... making doing things like GUI's and such a pain... since they lag behind the player.
|
Quote:
|
I don't fully read stuff... so you want a substitute formula or something for it?
|
Yea. Currently I'm using worldx(GraalControl.width, 0) to get the level x of the right window border of the client window, for example. But I need another way, because worldx() lags.
|
tx = mousex + (screenwidth-mousescreenx)/16
ty = mousey + (screenheight-mousescreeny)/16 I did not test this extensively, but it seems to me that it would work at least while the mouse is in the client window. |
worldx lags? Are you sure you aren't just implementing it wrong?
|
It doesn't 'lag' per say... but it doesn't update smoothly.
|
Quote:
Though, since it still lags behind...I think I'm doing something wrong. |
If this is in a custom movement script, try moving it before the change of the player's coordinates(or after... I forget), and it should make a big difference.
|
I guess its close. Its somewhat related to the player, maybe thats the reason. Though I cant place it inside the movement, its a gani script.
Edit: Actually, I guess I should have told you what I need this for exactly. I wonder why I didnt, should make things easier. I'm trying to mimic the behavior of the default nicks to not leave the Graal window if the player is still visible, so you will even see it if you are at the level edge or somebody is at the edge of your Graal window. Edit2: What I got also works perfectly clientside, just other players see it lagging behind a bit if what I'm trying to mimic (see above) is "happening" or however you want to call that. |
Quote:
|
I find gani scripts to buggy for nick/chat display. I just use a for (temp.p : players) loop that does a showimg for each player (on the level of course). The function for this I always call from my Movement script's onTimeout so I don't have to worry about that lag issue.
|
Quote:
|
What about if you use the player's x, y, and screenwidth to determine the x and y of the bounds of the current 'viewport'
ie. player's coords are (30,30), screenwidth is 1024, 30*16=480, the left bound should be playerx - 480 (give or take 16), and + 480 (or so) for the right hand bound. This could be locally run in a loop i think, though I am new to this language so I am not sure of it's loop/speed capabilities yet. idk.. just an idea, hope you caught what I mean :) |
I thought about using screenwidth and screenheight, but this wouldnt work when the player is near the level border and not centered anymore.
|
Or on a gmap.
|
The screen is moved depending on the player, so it's natural that worldx/y are not same as at the end of the frame depending on in which gani script you are retrieving them. For stuff like nicknames (things displayed for all players) it can actually be faster to use a weapon script and cycle through the player list and display it manually, instead of running a separate gani script for all the players.
|
Quote:
|
| All times are GMT +2. The time now is 07:55 PM. |
Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2026, vBulletin Solutions Inc.
Copyright (C) 1998-2019 Toonslab All Rights Reserved.