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.

Windows / [SOLVED] Unable to load sprite image in AGK Tier 2

Author
Message
Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 11th Feb 2019 13:55
Hello-
Using Visual Studio 2017 under Windows 10, I'm editing a copy of the "template_windows_vs2017_64" that I've placed in the same folder. I added a "media" sub-directory and placed a PNG file in it along with a text file. I can load the text file correctly using the standard library I/O commands, but when I add:

to the template.cpp file's Begin function, the sprite appears as the red "X" icon indicating some sort of failure. To check I also tried to load an image I have successfully used in AppGameKit Tier 1 with the same results. When I try to execute the "Step Into" function in VS to try and see myself where the error is, the code just skips over the function instead. I will note that when loading my text file I have to use "media\\" over "media/", but using "media\\" with the sprite loading doesn't change the outcome. What should I be looking at to fix this?

Note also that if I move this constant declaration out of 'Begin' and place it in the global space, the program gives me an unhandled exception.
Goo Goo G\'Joob!

The author of this post has marked a post as an answer.

Go to answer

puzzler2018
User Banned
Posted: 12th Feb 2019 10:07
Windows folder format is "\" so try changing the path from "/" to "\" and add a "\\" at beginning

so like

agk::LoadSprite("\\media\\kbButton_small.png")



Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 14th Feb 2019 06:09
Thank you for the response. I tried your recommendation and it didn't work. As an aside,

unsigned int const net = agk::LoadSprite("media/net.png");

...comes directly from the Pong tutorial that purports to be the Windows version. I've tried to compile this tutorial to verify that the graphic loads, but haven't been able to as the project is saved out with incorrect settings for Visual Studio 2017 (I have a separate thread on that issue).
Goo Goo G\'Joob!
Eqqman
9
Years of Service
User Offline
Joined: 15th Jul 2015
Location:
Posted: 17th Feb 2019 08:33
This post has been marked by the post author as the answer.
Found the solution indirectly from reading a post on a different topic: you need an additional folder in the project, so the media files go into (project root)\Final\media\ and not just (project root)\media. Confusing since the example Tier 2 projects don't include this folder and the documentation only refers to the "media" folder.
Goo Goo G\'Joob!

Login to post a reply

Server time is: 2024-11-17 22:41:42
Your offset time is: 2024-11-17 22:41:42