Determining Type
Blitz3D Forums/Blitz3D Programming/Determining Type
| ||
I have a game I'm working on that has many type of objects on the screen. All are Types, with Fields that reference the Pivots and Entities that make up the objects. I want to be able to click with the mouse and affect them. To that end, I use the NameEntity(ent, Handle(obj)) trick to so I can retrieve the object later. Make sense? When creating a ball for instance, I do: ball\obj = CreateSphere() NameEntity(ball\obj,Handle(p)) So, in on input I can do: If (MouseHit(1)) picked = CameraPick(Cam,MouseX(),MouseY()) If (EntityName(picked)) p.ball = Object.ball(EntityName(picked)) ...do stuff with the ball... EndIf EndIf My problem is that I have different object types that I wan to affect. A ball, and a platform for instance. Is there any way for me to determine the type of object that is stored in a handle? For instance: If (EntityName(picked)) If(Object.ball(EntityName(picked))) p.ball = Object.ball(EntityName(picked)) ...do stuff with the ball... ElseIf(Object.platform(EntityName(picked))) p.platform = Object.platform(EntityName(picked)) ...do stuff with the platform... EndIf EndIf Or, is there perhaps a better technique that I can use to get the same results? |
| ||
You should be able to use ... if Object.ball( entityname( picked ))<> null [convert to ball type ] else [convert to platform type] endif Stevie |
| ||
Brilliant! That worked perfectly! Thank you! |