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 / About cSprite, cImage, cInput, Anyone know how to use them?

Author
Message
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 04:34
I noticed there are many c++ classes in the AppGameKit include folder, but I don't know how should I use them. Can anyone give me a hand? I use Tier2, if I can use them directly , I think that will be better.

The Miracrea Games
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2013 05:14
I think those classes are meant for the AppGameKit engine's internal use, not for us to work with directly. Especially after reading the contents of cSprite.h and cSpriteMgr.h.

Don't mess with them or try to use them directly.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 05:16
I know. but I want to use them.

The Miracrea Games
xCept
21
Years of Service
User Offline
Joined: 15th Dec 2002
Location:
Posted: 1st Jun 2013 06:32
There hasn't been any more information shared about them since you posted originally in 2011. Basically 'use at your own risk - no documentation'.

http://forum.thegamecreators.com/?m=forum_view&t=189632&b=41
Hodgey
14
Years of Service
User Offline
Joined: 10th Oct 2009
Location: Australia
Posted: 1st Jun 2013 06:40 Edited at: 1st Jun 2013 06:41
The safest way to use them is to probably create pointers and then use the GetImagePtr() and GetSpritePtr() commands.

The following code seems to work fine on my mac:


But as Ancient Lady warns, unless Paul says otherwise, I wouldn't create sprites using the cSprite class directly; just use the pointers.

halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 14:22
I really wanna use cSprite style classes. Hope some one can give me a hand.

The Miracrea Games
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2013 17:37
You can create your own classes to do things to your hearts content.

Are you relatively new to C++ and object oriented programming? Is that what you need help with?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 17:38
I have been used C++ for 7 years. And I hope I Can use cSprite directly.

The Miracrea Games
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2013 17:45
Quote: "I have been used C++ for 7 years."

Cool, then OOP is something you are familiar with.

I really do think that the classes declared in the headers in the AppGameKit include files are not meant for us to use directly.

But I also didn't know that you could do what Hodgey showed. I can see that that would be fairly safe and an interesting way to do things. I just had visions of storing cSprite pointers in lists instead of the sprite ids. Hmmm.....

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 17:55
I wrote my own CSprite class, and I want it inherits from cSprite,such as follow:
CSprite : public cSprite
{

}

then that will be very useful for me.

Maybe only the TGC people know how to do this thing.

The Miracrea Games
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2013 18:06
It sounds like basic OOP.

But the TGC AppGameKit guys probably know more about some of the quirks, if any, to using the classes directly.

I would recommend staying away from doing things with the static class objects like g_pAllSprites and g_pLastSprite. Those are very probably the things that the AppGameKit engine depends on.

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 18:07
I tried to use cSprite, but there is no sprite show out in screen. So I don't know where is wrong.

The Miracrea Games
Ancient Lady
Valued Member
20
Years of Service
User Offline
Joined: 17th Mar 2004
Location: Anchorage, Alaska, USA
Posted: 1st Jun 2013 18:12
Did you create the sprite first with agk::CreateSprite and then get a pointer to it as shown in Hodgey's sample?

Cheers,
Ancient Lady
AGK Community Tester and AppGameKit Master
halley
13
Years of Service
User Offline
Joined: 27th Apr 2011
Location: China
Posted: 1st Jun 2013 18:16
Paul just now gave me some tip. I need to call Draw() and Update(). That will be ok.
Thanks Ancient Lady.

The Miracrea Games
Paul Johnston
TGC Developer
21
Years of Service
User Offline
Joined: 16th Nov 2002
Location: United Kingdom
Posted: 3rd Jun 2013 18:13 Edited at: 3rd Jun 2013 18:13
It is safe to create objects of the cSprite class and have it place nice with AGK. It can't have an ID associated and it won't be in any of AGKs draw lists, so it won't be properly depth sorted if transparent, but you can call cSprite::Update() and cSprite:b][/b]Draw() to update animation and draw it to the back buffer at any time, before or after the Render() command to draw the other sprites.

If you use only cSprite sprites and use no ID sprites then *in theory* it is possible to set up your own depth sorting algorithms and never call Render() or Update(), just Swap() when you want your backbuffer to go to the screen.

Login to post a reply

Server time is: 2024-05-03 02:13:40
Your offset time is: 2024-05-03 02:13:40