Type pointer
Blitz3D Forums/Blitz3D Programming/Type pointer
| ||
Is there any way to get a pointer of my type when I know one if its fields. Consider the following piece of pseudo code:Type mytype field entity% . . . end type Global a_type_instance.mytype . . . for c=1 to CountCollisions(an_entity) entity_collided = CollisionEntity(an_entity, c) if entity_collided <> 0 then a_type_instance = ReturnAPointer(entity_collided) next Function ReturnAPointer.mytype(entity%) ??? end function Note: I want to avoid to iterate the list of mytype Thanks |
| ||
No, but you can use the tried and tested object / handle method ... Firstly, when creating the type instance, store the type handle in the entityname like so .. n.mytype = new mytype n\entity = createcube() nameentity( handle( n ) ) Then when you find your entity collided, simply get the object like so .. Test.mytype = object.mytype( entityname( entity_collided) ) Test\Life = Tes\Life - 1 ;etc.... Should work just fine. Stevie |
| ||
I checked it and is working. This is what I was looking for! Thank you so much Stevie!!! |
| ||
Yay, Stevie G! Good answer! |
| ||
Well, sometimes when you get unstack you fill like a young boy he taste its first chocolate... |