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.

Dark GDK .NET / Basic2d.AnimatedSprite clone issue

Author
Message
Argon Knight
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Gastonia, NC, USA
Posted: 9th Aug 2010 03:09
How do I clone AnimatedSprites in dgdk.net?

in dbp, I can use the clone command to copy animated sprites.

but, in darkgdk.net (1.2 - may 09), the basic2d.animatedsprite class inherits its clone method from basic2d.sprite. I get a type cast error. I even tryed using CType() and got the same error.

my test code:


the exception:
Quote: "
System.InvalidCastException was unhandled
Message=Unable to cast object of type 'DarkGDK.Basic2D.Sprite' to type 'DarkGDK.Basic2D.AnimatedSprite'.
Source=Meteors-DGDKNET
StackTrace:
at Meteors_DGDKNET.SpriteTest.main() in C:\projects\games\mine\Meteors\Meteors-DGDKNET\Meteors-DGDKNET\SpriteTest.vb:line 12
at System.AppDomain._nExecuteAssembly(Assembly assembly, String[] args)
at System.AppDomain.ExecuteAssembly(String assemblyFile, Evidence assemblySecurity, String[] args)
at Microsoft.VisualStudio.HostingProcess.HostProc.RunUsersAssembly()
at System.Threading.ThreadHelper.ThreadStart_Context(Object state)
at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state)
at System.Threading.ThreadHelper.ThreadStart()
InnerException:
"


The error list reports:
Quote: "
Value of type 'DarkGDK.Basic2D.Sprite' cannot be converted to '1-dimensional array of DarkGDK.Basic2D.AnimatedSprite'.
"
Argon Knight
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Gastonia, NC, USA
Posted: 9th Aug 2010 04:36 Edited at: 9th Aug 2010 04:38
As a work around, I decided to revert to using Basic2d.Sprite. Its not important at this stage which one I use, but later it will. (My sprite is an animated spritesheet of a meteor rotating.)

ok,now, when I use Basic2d.Sprite.clone(), a new object is created, however its Position() method now gives me a "Object reference not set to an instance of an object". Accoding to the autos window, there is a new sprite object where there was none, so clone() is working. But the new instance has its member Image property set to nothing (null), where the original has the correct image reference. (If that is the problem, but its still an observation that would seem to predict another issue later)

So, I worked around that by using "new basic2d.sprite()" everytime I need a new sprite created.
Yoda Master
16
Years of Service
User Offline
Joined: 23rd Feb 2008
Location: Genova
Posted: 9th Aug 2010 16:33 Edited at: 9th Aug 2010 16:34
Hi Argon Knight!

The exception you get is the same I found in the Sound Class as you can read here, as first post http://forum.thegamecreators.com/?m=forum_view&t=141349&b=37.

You can work around this annoying issue by accessing directly to the DarkGDK.NET underlying interop library! You should add a reference to DarkGDK plugins dll, or a thing like that, and access the clone method by the CDarkGDK object!

If i'm not wrong, the Sprite and AnimatedSprite classes exposes their Id by the Id property, so that's all.

To do all more "object oriented", you can create an extension method which wraps all the calls to CDarkGDK.

If you need more help, just ask!

ByteStorms
Bytes from incoming years
www.bytestorms.com
Argon Knight
21
Years of Service
User Offline
Joined: 29th Aug 2002
Location: Gastonia, NC, USA
Posted: 13th Aug 2010 18:43
@Yoda Master

I took your advice and converted my code to using the CDarkGDK object. Everything is working now except for a pathetic frame rate. I'll have to refactor my code some more since I was going for an object based appraoch to figure that one out. I doubt its a dgdk issue since the FPS reports up to 60 fps. Either way, I got a workable game again.
Yoda Master
16
Years of Service
User Offline
Joined: 23rd Feb 2008
Location: Genova
Posted: 16th Aug 2010 17:55
I've developed a multiplayer card game with VB, some time ago and my fps were still to 60... even if the game is totally object oriented.

Try to fix your code, dgdk is very fast, exception made by its "text commands"....

Matteo

ByteStorms
Bytes from incoming years
www.bytestorms.com
APEXnow
Retired Moderator
20
Years of Service
User Offline
Joined: 15th Apr 2003
Location: On a park bench
Posted: 17th Aug 2010 00:39
Just so you are aware folks, the DarkGDK and DarkGDK.NET will cap the FPS refresh at 60fps irrespective of whether you choose to use fast update or not. This frequemcy is goverened by the setting under your advanced display settings though which may be able to be ramped up to increase overall frame rate. I know this problem hasn't been changed in DarkGDK C++ libraries since the first version was released.

Paul.

Login to post a reply

Server time is: 2024-03-29 01:45:15
Your offset time is: 2024-03-29 01:45:15