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.

iOS and MacOS / Using AGK commands in source files other than template.cpp?

Author
Message
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th Sep 2012 13:56
Is there a way, in Xcode, to use agk functions (agk::Sync() for example) in source code files other than template.cpp? I'm trying to use them in other .cpp files with agk.h included in their respective header files but I'm getting slapped with 20 errors categorised into Parser and Semantic. The errors state things such as NSString hasn't been declared. Simply including the agk.h header file in any file other than the default source files that come with the template seems to cause this issue. The funny thing is that the same code works perfectly on my Windows machine in VS2010.

For example:
web.h:


web.cpp:


Just having that in the project (doesn't matter whether I include "web.h" in the template .cpp or .h or not, will cause 20 errors.

Any ideas?

Cheers

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Sep 2012 18:32
Dumb question, but did you add the web.h and web.cpp files to your Xcode project? The project won't see files unless you add the files to the Classes folder in the project.

And, very important, make sure that the 'File Type' dropdown is set to 'Objective-C++ Source' (in the far right column when you select a file) for the files you add to the project. This way it treats the files correctly and uses the right paths and stuff. I was very frustrated with the same errors and finally found that solution.

And a caveat, you can use agk::Sync() to update a display, but don't use it in a loop that is waiting for any events like GetPointerPressed. In Tier 2 those processes are checked after each call to the agk::Loop() method by the main program. This is one of the only flaws (in my mind) about Tier 2. It means setting up state engines whenever you need to do something that waits on some sort of user input.

Cheers,
Ancient Lady
AGK Community Tester
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 29th Sep 2012 22:19 Edited at: 29th Sep 2012 22:20
Quote: "And, very important, make sure that the 'File Type' dropdown is set to 'Objective-C++ Source' "

That was it. You're a legend AL, thanks!

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 29th Sep 2012 22:47
Always glad to help. I found the solution by googling several of the errors and one finally indicated the solution that worked.

Happy Programming!

Cheers,
Ancient Lady
AGK Community Tester

Login to post a reply

Server time is: 2024-04-26 20:20:10
Your offset time is: 2024-04-26 20:20:10