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 / QUESTION that does not require snippets

Author
Message
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 6th Oct 2013 20:06
Is there prescedence for UDT fields to swap when passed to a function?

For example, pos.X=10 and pos.Y=20 outside the function.

But in the function it is pos.X=20 and pos.Y=10

I copied/pasted the function and calling code into another project and it works fine. I then copied/pasted from the new project into the old, and still same problem.

I am not going to spend all day on this, I am just asking a question. (see first sentance)

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 6th Oct 2013 20:08 Edited at: 6th Oct 2013 20:13
Okay, maybe a little snippet.



Inside the function I am getting pos.X=20 and pos.Y=10.

I copied/pasted the same exact code into another project and I get the correct results. But in the original code, I need to use this instead:



In order for it to work correctly.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Oct 2013 21:29
First make sure you are using the latest beta of AppGameKit, older versions have problems with passing UDTs.

Your code has some errors. Here's a working example.



Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Oct 2013 22:58
Yup, you forgot to declare the variable pos used in the function call as a _position_ so the compiler didn't really know what to do with it.

But real problem is your UDT definition:


It should be (assuming X and Y are being used for sprite/pointer positions which take floating point):


And the compiler probably should have complained about your _position_ definition.

(See, the code snippet was definitely needed so that we could see how the UDT was being defined.)

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
mindsclay
12
Years of Service
User Offline
Joined: 1st May 2012
Location: Rocklin, CA, USA
Posted: 6th Oct 2013 23:02 Edited at: 6th Oct 2013 23:04
I checked my code and I have it correct. I merely typed my snippet incorrectly.

I have the latest beta from my product list. Is there another way to get the latest?

I am seeing this happen in places it wasn't happening yesterday.

Anyway, the problem is a swapping of the variables when it is in the function. I have no errors from the compiler. I have the values printing to screen and I can see the variable outside the function and inside the function. The variables are swapped.

www.mindsclay.com
lucifermagus.mindsclay.com (not working with Firefox)
Digital Awakening
AGK Developer
21
Years of Service
User Offline
Joined: 27th Aug 2002
Location: Sweden
Posted: 6th Oct 2013 23:12
Exceeding indexes for UDT arrays does not always generate an error message. If you have random things happening it could be that. Otherwise I would guess it is your code.

One way to find the problem is to delete large chunks of code until it runs. With the UDT array bug in mind, your problem could be anywhere.

Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 6th Oct 2013 23:13
The 'My Product' list has the latest beta (v10819).

Are you sure that the UDT variable you are setting and passing into the function has been properly declared before you use it in any way? (It isn't in your snippet, but maybe that was a typo as well.)

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master

Login to post a reply

Server time is: 2024-05-07 08:56:11
Your offset time is: 2024-05-07 08:56:11