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 / Why tier2 functions return always a valid handler

Author
Message
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 5th Sep 2013 06:37
I started my adventure with Tier 2 this week, and while testing my app, I noticed that a command like this:

img_font = agk::LoadImage("media/fonts/quote_font.png");

will always return a valid number, even if the image passed doesn't exist. It doesn't make any sense. Are all functions like that?

Thanks

----------
Paulo
http://c64programming.wordpress.com
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 5th Sep 2013 16:22
Are you sure about that?

What version of AppGameKit are you working with? (I can test and see if I see the same results.)

The function should not return a number if the image does not exist.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 5th Sep 2013 17:03 Edited at: 5th Sep 2013 17:10
I'm using 10818. So it is a small test code based on template.

The call to

img_font = agk::LoadImage("media/fonts/quote_font.png");

always return 10001 (or something like that - I don't have access to the machine right now)

I forced a wrong file name/path and it still shows me the same value.

I first noticed that when I couldn't see the font being loaded although it was showing some "dirt". After checking the code I saw I had a typo in the file name.

I also was forcing img_font to be zero before calling the function just to be sure.

Thanks

----------
Paulo
http://c64programming.wordpress.com
Paul Johnston
TGC Developer
22
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 5th Sep 2013 19:42
If AppGameKit can't find an image it loads the Missing.png image which is a red cross so that it's obvious an image is missing. Therefore it did create a valid image, just not the one you were expecting. If you want to check if the image file exists you can use the agk::GetFileExists() command.
MobileCreator
13
Years of Service
User Offline
Joined: 1st Jun 2011
Location: Ottawa - Canada
Posted: 5th Sep 2013 20:20
Hey Paul,

thanks for the information. I didn't notice it was a red cross because I was using it as Font.

However, in my point of view, functions that requires external assets should fail if the desired asset isn't found. It would be easier to handle errors using just the LoadImage function instead of calling two functions to do the same job.

Of course, it is not something that I can't leave without, but the behaviour I was expecting seems more "standard" to me when working in C/C++.

Thanks!

----------
Paulo
http://c64programming.wordpress.com

Login to post a reply

Server time is: 2024-11-24 19:57:45
Your offset time is: 2024-11-24 19:57:45