Object/Background Issue (SOLVED)

Started by DazJ, Sat 28/06/2008 10:04:28

Previous topic - Next topic

DazJ

An object I am using in one of the rooms is literally the bottom right quarter of the original background drawing but with some slight alterations - when the object is called this will create an animation-style effect.

However, despite being the original background drawing EXACT bottom right corner, the object seems IMPOSSIBLE to align up in AGS. It can appear fine in AGS itself but when I run the game the object is always slightly off.

I'm running the game at 800x600.

Any suggestions?

hedgefield

I've had this issue myself (I don't know which version of AGS you're running, I encountered it in 2.62). The solution I used was adding a row of transparent pixels to one side of the image, to effectively 'pad' it so it would line up with the actual background.

I think when you move the object around in AGS, it used the 320x240 coordinate system, so when you run a resolution higher than that, it will move by 2 pixels or 4 pixels instead of 1. You can bypass that by padding it with that extra pixel like I described.

Khris

Almost, 800x600 is handled as 400x300 internally, so make sure that the object's dimensions and coordinates are even numbers. (They should be anyway, if the object's supposed to make up a quarter? Use a 400x300 object and place it at 400;598, that should do it.)

DazJ

Cheers guys, it's very much appreciated.

However, the object image isn't exactly a quarter but either way I've made sure that the image has an even amount of pixels for both height and width and I STILL have the same problem.

Grrr....it's really bugging me now, lol.

Khris

Is it off horizontally or vertically? Or both?

DazJ

Hi Khris...horizontly. When I run the game it's either what appears to be 1 pixel to the left or 1 to the right. Then of course I move the object 1 pixel forward or back in the editor and then it's too far to the direction I moved it....if that makes ANY sense lol.

Khris

Hmm, then do like largopredator suggested and add a line of pixels to the left of the sprite.

DazJ

Tried that too, still had the same problem. I really can't understand it.

Looks like I'll have to just animate the background instead, although this will lead to a lot of problems.

Cheers anyway :)

Khris

I'm gonna test this now and report back. (Btw, don't rely on how it's displayed in the editor; check it inside the game, if you didn't.)

DazJ

Thanks Khris, I await your results :)

RetroJay

Quote from: DazJ on Sat 28/06/2008 17:37:33
Hi Khris...horizontly. When I run the game it's either what appears to be 1 pixel to the left or 1 to the right. Then of course I move the object 1 pixel forward or back in the editor and then it's too far to the direction I moved it....if that makes ANY sense lol.

Hi DazJ.

It makes perfect sense as I have had the problem myself (numerous times).
I posted sometime back now about the same thing. People then told me about having objects on "even coordinates" but this didn't always seem to work.

I have found that if it is out (horizontaly) then I keep adding a line of transparent pixels either to the left or right and sometimes both until it is correct.
and the same goes for Verticaly (except the pixels get added to the top or bottom or sometimes both).

However in some cases I have had to add lines of transparent pixels all around my object to get it to align properly.
I have found it to be a case of try, fail, try, fail, try and eventually YES!! just how I want it.

Hope this helps.
Jay. 

Khris

I've played around with this and luckily it can be done comfortably without trial and error.
I was even able to place a 355x265 object correctly.

First try: 400x300 object, the bottom-right quarter of the background. Editor coords: 200, 300
-was displayed fine in both editor and game

Second try: Cropped the object to 398x300, taking away the left edge. Editor coords: 201, 300
-was displayed fine in both editor and game

Third try: Cropped to 355x300, this time taking away the right edge. Editor coords: 201, 300
-was displayed fine in both editor and game

Fourth try: Cropped to 355x265, removing a portion of the bottom. Editor coords: 201, 282
-was displayed fine in the editor, off in the game
added a transparent line at the bottom, changed Y to 283
-was display off in the editor, but fine in the game

Conclusion:
With a bit of careful planning you can skip trial and error and even adding lines of pixels.
Don't rely on the editor's display, always check it in-game.
If the object is off horizontally, add a line of pixels to the left, then adjust the coordinate if necessary.
If the object is off vertically, add a line of pixels to the bottom, then adjust the coordinate if necessary.

DazJ

When you say add a line of transparent pixels round the edge, do you mean draw the line OVER the actual sprite or ADD it to the end?

Khris

add = ADD, right?
Add them, like, put more pixels to the sprite, you know, additional ones, increase the width/height, embiggen it, change the canvas size to a greater value. ;)

Keeping the dimensions won't change the position, regardless of the color.

hedgefield

That's how I did it with an animated fan on a wall. Because it had transparency and blur and all that, I couldn't just make it an object itself, so I took a chunk off the background and used that as object. It was a little offset, so I added rows of colored pixels around the outside of it until it aligned (AGS makes them transparent).


DazJ

THANK THE LORD!!!! lol

The transparent lines worked - don't ask me how, they just did!

Thanks to all those who helped, I couldn't have done it without you!

SMF spam blocked by CleanTalk