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 / (Tier 2) Using multiple classes

Author
Message
JakeC0527
7
Years of Service
User Offline
Joined: 2nd Jun 2016
Location:
Posted: 2nd Jun 2016 03:57
For the sake of utilizing objects and classes, I changed to Tier 2. I got everything working, except for classes. I am currently using Microsoft Virtual Studio 2013 and used the correct template that came with my install of AGK. However, whenever I try to use an AppGameKit command in a cpp file besides the template (for example, agk::AddVirtualButton(3, 200, 670, 50), I get an access error saying, "First-chance exception at 0x00438D75 in Template.exe: 0xC0000005: Access violation reading location 0x00000000. If there is a handler for this exception, the program may be safely continued." With a ton of testing, I realized that this error appeared every time an AppGameKit command was called outside the template file. Is there any way to fix this?
Stab in the Dark software
Valued Member
21
Years of Service
User Offline
Joined: 12th Dec 2002
Playing: Badges, I don't need no stinkin badges
Posted: 3rd Jun 2016 19:26
Try putting this at the top of cpp file.

#include "agk.h"
The coffee is lovely dark and deep,and I have code to write before I sleep.
JakeC0527
7
Years of Service
User Offline
Joined: 2nd Jun 2016
Location:
Posted: 4th Jun 2016 21:24
I have tried that, but it still returns the error.
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 12th Jun 2016 18:57
Quote: "First-chance exception at 0x00438D75 in Template.exe: 0xC0000005: Access violation reading location 0x00000000"

Hi Jake. This error is almost always the result of dereferencing a null pointer. It's hard to be any more specific than that without seeing the code. Can you show us the code? If that's not practical, can you give us the line on which the error occurs and the stack trace?
insignia008
7
Years of Service
User Offline
Joined: 15th Jun 2016
Location:
Posted: 15th Jun 2016 19:15
I can confirm that I could not use #agk.h on other classes. I'm on xCode, see image attachment for the error.

I tried putting on the header file, then on the CPP file, then both. Build fails all the time. My code that works is below (I commented out agk.h and it builds properly, otherwise it won't)

I am using the template provided for iOS xCode Tier 2.








Attachments

Login to view attachments
Lucas Tiridath
AGK Developer
15
Years of Service
User Offline
Joined: 28th Sep 2008
Location: Kings Langley, UK
Posted: 16th Jun 2016 21:36
Insignia I think you are facing a different issue to Jake (you have a compile time error whilst he is facing a runtime error). Could you check that you are compiling your additional cpp files as Objective C rather than as C++? By default, Xcode assumes files with the extension .cpp are C++ files, but the agk headers on OS X are written in Objective C and so cannot be parsed by a plain old C++ compiler.
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 20th Jun 2016 00:48
It would help to see your template.cpp file get an idea of the order of what you are trying to do.

The order is very important. You cannot call any AppGameKit functions before the app::Begin() method starts.
Cheers,
Ancient Lady

Login to post a reply

Server time is: 2024-03-28 09:11:13
Your offset time is: 2024-03-28 09:11:13