Yet another version! While playing with square Sprites without transparency I found problems with fragments of the edges of Sprites being left behind. The problems were masked in the Demo because the edges of the Sprites there are mainly transparent and the displacements on each tick were only a few pixels. These are mainly solved (I hope!) but a GameWindow method is now provided to erase a Sprite from its' current position in cases where it might be necessary.
To provide more control over a Sprites' animation a Sprite now has a FrameCount property to get the number of frames in the animation and a boolean FrameForwards property to get or set the direction of animation. Previously the direction could be set by the SetFrameDirection method but could not be read back.
To allow the animation to be changed a Sprite now has LoadBitmap and LoadFile methods. The parameters for these are the same as for New2 and New3.
GameWindow now has an EraseSprite(index) method for use when manipulating a Sprite in some way might leave fragments of it visible. This might be before changing the animation to a smaller set of bitmaps or before moving a Sprite by changing its' X or Y properties.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
I use square sprites without any transparency and have never noticed anything odd. They move constantly.
If moving to x,y would this routine need to be called for every movement and will it slow it down (if the artefacts are present)?
A question for your experience and knowledge of how sprites work. I know this can be done outside the sprite, but could there be any advantage, speed wise or any other way, if a sprite had a destination property (dX,dY) such that the sprite would automatically travel toward it and upon arrival trigger an event?
My thinking is that in this way the testing of each pixel position passed would be by internal code rather than user (external) code.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural
Device:Viewsonic VPad7, Android 2.2.2
Trust me , between versions 1.21 and 1.25 there was a problem even if you didn't notice it. I don';t know if it was in earlier versions but I have changed a lot of the library internally and am not going back to find out!
Quote:
If moving to x,y would this routine need to be called for every movement
Depends what you mean by movement. Basically if you are going to assign to X or Y then you may need to erase the sprite first as the library will now no longer know where it was and so won't erase it properly. If you are letting it move itself each tick you don't need to do it. It will be obvious if it is needed.
Quote:
but could there be any advantage, speed wise or any other way, if a sprite had a destination property (dX,dY) such that the sprite would automatically travel toward it and upon arrival trigger an event?
Yes, it should be a lot faster. I'll have to think about whether such a facility could fit in the present architecture of the library.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural
Device:Viewsonic VPad7, Android 2.2.2
if a sprite had a destination property (dX,dY) such that the sprite would automatically travel toward it and upon arrival trigger an event?
This version includes such an event. However I haven't implemented the "automatically travel toward" bit, you will have to calculate and define its direction yourself.
Version 1.27 changes are as follows.
GameWindow has a new CollisionDestination event.
Sprite has new IsAnimated, DestinationX, DestinationY and HasDestination properties.
There is a help file describing the changes in the archive.
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Very many thanks agraham. I just need time to try all this.
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural
Device:Viewsonic VPad7, Android 2.2.2
I am having difficulty with the data array but it must be me.
Quote:
Dim Type(x, y, z, name)Spritedata
....
Dim Spritedata(4) ' make a new array
... ' set it up
Sprite.DataArray = Spritedata() ' assign it to a Sprite
The second Dim gives the error that SpriteData is already in the dictionary.
I tried Dim Type(x,y)SpriteData(4) which is OK but
Sprite.DataArray = Spritedata() gave the error...
Object of type 'System.String[,]' cannot be converted to type 'System.String[]'
Can you advise please
[Edit]The destinations work a treat!!
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural
Device:Viewsonic VPad7, Android 2.2.2
The second Dim gives the error that SpriteData is already in the dictionary.
I can't see anything wrong with that code. The only way I think you can get that error is if two Dim statements for the same array are in Sub Globals, only the Type statement must be in there. If it persists you will need to post some code that shows the error so I can see the context. Look at the DataDemo.sbp in the archive which contains that same code.
Quote:
I tried Dim Type(x,y)SpriteData(4) which is OK
Actually it's not. That makes SpriteData into a two dimensional array hence the comma in "String[,]" in the error message. The library expects a single dimension array, hence the error.
EDIT:- The occurrence of the "cannot be converted error" implies that the "Dim SpriteData(4)" statement is not being executed before "Sprite.DataArray = Spritedata()" as that converts it back to a one dimension array. Looks like the execution sequence is wrong. Each Sprite needs its own array. If you don't re-Dim it for each Sprite they will share the same array - which you might or might not want to do, most likely not!
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Yes I did have both Dim's in Globals Sub. My problem is one of comprehension. I cannot seem to get to grips with this 'sort of indirection' or 'temps' that we mentioned earlier, instead of direct.
I don't see why each of the Type(x,y,z) doesn't become one entity and then placed in a single dimension.
I am trying to assign points((2,3),(3,7)...) to a sprite. That is why I did what I did.
I cannot seem to translate that using the example.
Sorry to be thick but perhaps I could ask for your help on that specific problem?
[Edit]
I also tried in app_start...
Dim points(4)
Points(0).x= 49
Points(0).y=1
[Edit 1]
The example line 35 'seems' to only permit one array element of x,y,z but it is dimensioned for 3, how to add Data(1)??
In the example line 24 I don't see why...
& CRLF & "Array(1) = " & arr(1))
cannot become...
& CRLF & "Array(1) = " & spr.DataArray(1))
Is it for the same reason as Spr.Value = Spr1.Value ?
[Edit 2]
It looks to me that x,y,z have been converted to data(0)=x,...(1)=y etc. Which means that there is only one true element permitted as I mentioned above so...
Spr.DataArray = data() where data is as above
__________________
You never stop learning until you die.
Sometimes I think I am dead.
Sometimes others think I am dead!
Homesite: http://www.don-simmonds.co.uk for Libyan Mural
Device:Viewsonic VPad7, Android 2.2.2
Last edited by enonod : 07-06-2009 at 12:16 PM.
Reason: Dim points(4)
Dim Data(2,4) ... x = 0: y = 1: z = 1: name = 3 Data(0,x) = 0 Data(0,y) = 1 Data(0,z) = 2 Data(0,name) = 3
In these examples Data is a variable, Dim creates the array and assigns it to the variable. If you want a new array for each Sprite you need to do a Dim for each one to create a new array. The old array still survives if you have assigned it to a Sprite and you can assign it back to the array variable by