monkey equivalent isKindOfClass?
Monkey Forums/Monkey Programming/monkey equivalent isKindOfClass?
| ||
Just wondering if there was an equivalent in monkey to check wether an object is of a certain class? I know its possible in Obj-C and I have used it a lot but not sure if other targets and monkey support it... |
| ||
local o:Int=35 if Int(o) (returns true) if Float(o) (returns false) Float(o) converts o into a float |
| ||
Ok I had to think about that for a second... your example pointed me in the right direction but fails if you swap the if around as ints can be cast into floats and vice versa. Tested it with class objects of my own and it does indeed work, you cant cast from class to class... don't know why I didn't think of that. Thanks! |
| ||
yw :) you cant cast from class to class. well you can if one extends the other |
| ||
how can i check this:If Camera(entity) .... Camera is extends Entity, but how can i test that? My function gets the object as type of "Entity", but it can be a mesh, a light, camera ....... |
| ||
ok, i am tired ... works like other types ... should go to bed :DFunction MoveEntity:Void(entity:Entity, x:Float = 0.0, y:Float = 0.0, z:Float = 0.0) If Camera(entity) ' now we have to transform every object in this f.. fine world EndIf entity.move(x, y, z) End |