Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

AppGameKit Classic Chat / AGK messing with my sprites

Author
Message
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 7th May 2012 22:34 Edited at: 7th May 2012 22:48
When I try to use 2 color sprites, black and white, with transparancy, AppGameKit add antialiasing around the sprite, so it looks horrible, it happens if the sprite is moving, or if the resolution is scaled.

The first picture, is 1x1 resolution, and the tree is OK, but the witch is not, since she is moving.

In the second picture, the screen is scaled, and you can see the tree does not look good at all... Is it possible to fix this?





Btw, this is a smal game I made after finding an old drawing from the early 90's, of a game I wanted to make on the Commodore 64. Hehe, better late then never. I made it to test the new ad-commands. Feel free to try it out for free at the android play store, search for " Midnight Horror "

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 8th May 2012 00:34
Probably fixed with SetDefaultMagFilter(0) and SetDefaultMinFilter(0) commands. By default they are set at 1 and will cause this edge filtering effect.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 00:45
DVader Does the edge filtering happen only when resizing?

Sometimes I notice little black lines in my project, I think it's a similar problem
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 00:45
And why are SetDefaultMagFilter() and SetDefaultMinFilter() set to 1 by default?
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 8th May 2012 09:32
bjadams, the edge effect only happens on scaled sprites in my experience. As for the black lines, are the sprites animated or grabbed off a sprite sheet? I have experienced this only when using the automatic grabbing, and setup of animation frames using setspriteanimation(). I haven't necessarily always used them as animations, sometimes I have used animation frames as a fast way to grab different blocks and such off one sheet.
It is quite annoying and no amount of changes to the magfilter or SetSpriteUVBorder seemed to help much. As a bonus it only did it on my android phone. It worked flawlessly on a slightly different model. It seems to grab any part of the sprite below the one being grabbed, and filter it into the bottom of the actual grabbed image, giving an ugly glitch anywhere the sprite is transparent.
I think the filter commands are set to 1 as default to make scaling look smooth. Plus I only think it happens when sprites are overlapping, but don't quote me on that :p .

AnX
14
Years of Service
User Offline
Joined: 17th Sep 2010
Location:
Posted: 8th May 2012 10:40
I had the same problem with font image.
Try to round() sprite x and y positions if that doesnt work try to load image with even width and height like(124 436 932 38 834 ... ) and dont scale it.
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 8th May 2012 12:40
Another problem is that when I download it from Google Play, it install 2 icons in the installed programs menu, and when you click on the left one, the screen goes black, and after som time an error appear, saying the program crashed. If you click the right icon, it starts up normally... What can be the cause?

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 14:05
Spites are 1 sprite per file, no animation and no spritesheet.

i get the black lines on ios when agk shrinks the 960x640 display in half.

on windows all works ok
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 8th May 2012 18:00 Edited at: 8th May 2012 18:01
The filter thing did the trick! Thank you DVader!

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 8th May 2012 19:10
Ah thought it would, Impetus73, glad to help.

Bjadams, it sounds like the scaling within agk might be causing those black lines. Is this using the player, or after compiling yourself? The player used to be a bit ropey to put it mildly. I haven't had chance to try it in months now though, as I know no one with an iphone at the sec. Can you force it into working at full res to see if it is scaling that is causing it?

One thing I can say has also cause black lines, was to accidentally use setvirtualresolution, and a little later setaspectratio. That caused big evenly spaced black lines along the display. It had me stumped for a while, until I noticed I had somehow managed to rem back in the set aspect ratio line from the initial wizard code. Again on PC that didn't even register as a problem. The android instantly showed it.
I can only suggest playing around with some of the various commands may help. Such as setUVoffset, setUVborder, setdefaultmag/min filter, SetResolutionMode etc. But as I said before, sometimes I have just not been able to clear the problem at all. I had to chalk it up to a possible bug that only shows on some android devices and leave it alone. I also couldn't reproduce it in a small test program. If I tried doing a similar thing with a small program the bug would stubbornly refuse to happen.

Sometimes you just have to put it to one side and move on to a different project, or it can drive you quite mad lol!

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 8th May 2012 19:56
the black lines happen on t2.

no player or bytecode t1
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 8th May 2012 21:24 Edited at: 9th May 2012 08:15
When I click an ad, and it opens a browser, the game pauses, but the music continues, and when i close the browser, or press back button, I go back to the game, but the SetDefaultMagFilter() and SetDefaultMinFilter() are reset to 1 !!!

This must be a bug! I wish there were a GETBROWSEROPENREQUESTED() and GETRETURNEDFROMBROWSER() command, so I could trap the ad clicking, and do stuff...

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th May 2012 01:43
Impetus73, not sure about that, maybe the new resume command may help? The ad commands are new and are obviously throwing you out of your app and into your browser, so a loss of focus is probably causing it. I've not played beyond the openbrowser command, and that was literally all I did.

Bjadams, I don't use tier 2 at all, so cannot really help with specific tier 2 commands. I just assume they are mostly the same as tier 1 in general. Just that you are accessing the libs directly. If you can recreate the problem with a small program, and post it up on a new thread, perhaps someone can give you a solution.

bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 11:45
DVasder, commands are the same, doesn't matter if its t1 or t2
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 9th May 2012 18:36
DVader, what resume command is that? I'll just make a timer that will reinitialize the filters at given intervals for now.

The open browser command, is dangerous! I made a simple test in a loop, if i clicked a sprite, it should open a browser window. Problem is it's running that loop like 1000 times/sec, so when I pressed the sprite, my computer spent the next 40min opening new sessions of internet explorer... I had to wait, and then manually close it all... Be warned! I set up a timer, and a flag, so it would only accept sprite press, if timer had reached it's limit since last press.

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2012 19:19
DVader was talking about the 'GetResumed()' command. This is supposed to detect when the app gets reopened after having been put into the background.

Unfortunately, I've only seen this work on my Android device. It didn't trigger in Windows, Mac or iOS.

I'm going to make a simple app and see if I can create a good example to show it not working and submit it on the bug page.

Cheers,
Ancient Lady
DVader
20
Years of Service
User Offline
Joined: 28th Jan 2004
Location:
Posted: 9th May 2012 19:51
Oh lol, Impetus73, never use a command like that in a loop without some error checking!
Ancient Lady, I haven't really played with resume at all yet. I just thought it may help to keep/restore the game graphics settings (as impetus73 said the mag filter was being reset to 1). There could well be a bug in it as it is new. So far the new update has presented me no major problems. Apart from using frame 0 crashes AppGameKit completely (no error just a fatal exception) and it took me a while to locate the problem because of this.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 9th May 2012 19:58
The GetResumed command only lets you know that you have been reopened after going to the background (once it works).

From what I've been able to test, on iOS and Android the app pretty much stops doing anything when sent to the background and starts back up where it was when reopened. On Mac and Windows, it keeps running when minimised.

Cheers,
Ancient Lady
Impetus73
13
Years of Service
User Offline
Joined: 28th Aug 2011
Location: Volda, Norway
Posted: 9th May 2012 23:18
Hmm.. After altering my .PNG files of the tree and witch, they suddenly appeared normally, so I guess the SetDefaultMagFilter() and SetDefaultMinFilter() commands were not the problem. I guess they are working properly afterall.

I originally had a 24bit .PNG file, where the tree had the color value of 0,0,0 and the background 255,255,255 with the background as transparent. I changed it to white tree and black background, then used setspritecolor to dim it almost black, then all worked fine. I guess AppGameKit has a problem with white being the transparent color?

----------------
AGK user - novice
Did Amiga / AMOS programming in the 90's, just started programming again with AGK.
bjadams
AGK Backer
16
Years of Service
User Offline
Joined: 29th Mar 2008
Location:
Posted: 9th May 2012 23:51
or maybe you graphic file has an actual white blur outline and it does not show in your pain package. try another graphic file for a test
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 10th May 2012 03:03
Quote: "I originally had a 24bit .PNG file, where the tree had the color value of 0,0,0 and the background 255,255,255 with the background as transparent."


This is a problem when the resolution of the image doesn't exactly match the resolution of the device and some filtering is needed (turning off filtering would mask this problem, as you found out). If it must blend along the edge of the image where one pixel is black and opaque, and the other is white and transparent, the resulting pixel will be grey and semi-transparent, and therefore visible, producing a lovely grey border around the black tree.

To solve this you can set the color of the background to be black as well. SetSpriteColor to black is a nice workaround as it will force all the pixels to black no matter what color they are in the image.

Login to post a reply

Server time is: 2024-11-23 10:54:22
Your offset time is: 2024-11-23 10:54:22