Download the free trial version
Basic4android Video
Features
Tutorials and manuals
Showcase
Screenshots

Go Back   Android Development Forum - Basic4android > Basic4ppc (Windows Mobile) > Basic4ppc Wishlist
Documentation Wiki Register Members List B4P Search Today's Posts Mark Forums Read

Basic4ppc Wishlist Missing any feature?

Sprite attributes (properties)

Reply
 
LinkBack Thread Tools Display Modes
  #31 (permalink)  
Old 07-03-2009, 06:00 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

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.
Attached Files
File Type: zip Sprite1.26.zip (8.2 KB, 11 views)
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.

Last edited by agraham : 07-03-2009 at 06:03 PM.
Reply With Quote
  #32 (permalink)  
Old 07-03-2009, 07:26 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

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
Reply With Quote
  #33 (permalink)  
Old 07-03-2009, 07:40 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by enonod View Post
I ... have never noticed anything odd
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.

Last edited by agraham : 07-03-2009 at 07:42 PM.
Reply With Quote
  #34 (permalink)  
Old 07-04-2009, 06:39 AM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

Thank you again for your valuable time.
__________________
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
Reply With Quote
  #35 (permalink)  
Old 07-04-2009, 05:27 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by enonod View Post
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.

Last edited by agraham : 07-04-2009 at 06:28 PM.
Reply With Quote
  #36 (permalink)  
Old 07-05-2009, 12:11 PM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

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
Reply With Quote
  #37 (permalink)  
Old 07-06-2009, 08:04 AM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

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

Last edited by enonod : 07-06-2009 at 08:40 AM.
Reply With Quote
  #38 (permalink)  
Old 07-06-2009, 09:02 AM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

Quote:
Originally Posted by enonod View Post
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.

Last edited by agraham : 07-06-2009 at 09:14 AM.
Reply With Quote
  #39 (permalink)  
Old 07-06-2009, 09:44 AM
enonod's Avatar
Basic4ppc Veteran
 
Join Date: Oct 2007
Location: U.K.
Posts: 324
Default

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)
Reply With Quote
  #40 (permalink)  
Old 07-06-2009, 12:31 PM
agraham's Avatar
Basic4ppc Expert
 
Join Date: Jul 2007
Location: Cheshire, UK
Posts: 5,953
Awards Showcase
Innovator medal Beta Tester Forum Contributer 
Total Awards: 3
Default

A structure is a short hand for one dimension of an array to make access to elements of the array more intuitive
Code:
Dim Type(x, y, z, name)Data
...
Data.x = 
0
Data.y = 
1
Data.z = 
2
Data.name = 
3

Is equivalent to 

Dim Data(4)
...
x = 
0: y = 1: z = 1: name = 3
Data(x) = 
0
Data(y) = 
1
Data(z) = 
2
Data(name) = 
3
For an array of strutures
Code:
Dim Type(x, y, z, name)Data(2)
...
Data(
0).x = 0
Data(
0).Y = 1
Data(
0).z = 2
Data(.).name = 
3

Is equivalent to 

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

Code:
spr1.Value = gw.Sprite1
Data() = spr.DataArray
sprname = Data.name 
' or sprname = Data(3)
__________________
Sorry, but I don't answer questions by PM or email.
Please post your queries in the forum.
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are Off
Pingbacks are Off
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
Properties module - useful module for working with properties / ini files Erel Code Samples & Tips 2 10-13-2011 10:02 PM
Assembly properties Pachuquin Questions (Windows Mobile) 1 05-05-2009 06:42 PM
Compiled Properties Zenerdiode Basic4ppc Wishlist 2 03-06-2009 08:08 PM
Evaluate properties Offbeatmammal Basic4ppc Wishlist 0 06-02-2008 07:23 AM
More properties for panels RandomCoder Basic4ppc Wishlist 0 07-12-2007 09:48 PM


All times are GMT. The time now is 03:50 AM.


Powered by vBulletin® Version 3.6.12
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.
Search Engine Friendly URLs by vBSEO 3.3.0