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 / How do I call a function in a function parameter?

Author
Message
Azamaticon
2
Years of Service
User Offline
Joined: 1st Oct 2021
Location:
Posted: 4th Feb 2024 19:40 Edited at: 4th Feb 2024 19:42
Hello everyone, please tell me if there is a way to pass the function name to another function as a parameter. To have another function accept this function and run it?

I wrote a small library for myself that creates dialog boxes. I need to be able to easily process the buttons in the dialog box and launch the desired function. I'll give you an example:


blink0k
Moderator
11
Years of Service
User Offline
Joined: 22nd Feb 2013
Location: the land of oz
Posted: 4th Feb 2024 20:51
Unfortunately that, as you have described, is not possible
Phaelax
DBPro Master
21
Years of Service
User Offline
Joined: 16th Apr 2003
Location: Metropia
Posted: 5th Feb 2024 20:55
You'd have to do something like this

Tiled TMX Importer V.2
XML Parser V.2
Base64 Encoder/Decoder
Purple Token - Free online hi-score database
Legend of Zelda
Pixel-Perfect Collision

"I like offending people, because I think people who get offended should be offended." - Linus Torvalds

Raven
19
Years of Service
User Offline
Joined: 23rd Mar 2005
Location: Hertfordshire, England
Posted: 6th Feb 2024 14:48
Function Pointers / Objects aren't supposed to exist in AppGameKit Teir 1...
They do, but it's a bug and their behaviours inconsistent.

Now with this said, the scenarios for needing a Function Pointer are quite rare (esp. in C++ with virtualisation as a built-in aspect).
Your own example really is unnecessary.

Personally, and I say this as I have written my own UI Library...
I would use a Common Window., which uses Binary Flags to determine the "Common" Buttons to use.
These would be ABORT, CANCEL, RETRY, YES, NO, OK, CONTINE, IGNORE

And as there are only a few different variants you'll ever _actually_ use these could themselves be defined as Flags
ABORTRETRYIGNORE
CANCELTRYCONTINUE
HELP
OK
OKCANCEL
RETRYCANCEL
YESNO
YESNOCANCEL

As none of these buttons are used / defined twice., you pre-define, create and load the resources as part of the API then simply have them "Offscreen" or "Not Visible" unless they're in usage.
If you need help with Binary Flags., check the Code Snippets Forum as I have a fairly comprehensive Bit Operation sample on there.





adambiser
AGK Developer
8
Years of Service
User Offline
Joined: 16th Sep 2015
Location: US
Posted: 11th Mar 2024 17:40
As others have mentioned, this can't be done in Tier 1. I wish it could be done as I have a generic state machine with states that can call a function every frame.

It would probably be best to do something like this in your case:


Login to post a reply

Server time is: 2024-04-27 14:40:38
Your offset time is: 2024-04-27 14:40:38