sprite in a type?
Blitz3D Forums/Blitz3D Programming/sprite in a type?
| ||
I am trying to draw my characters (who are very tiny) using sprites. Right now, I try to load their image with loadSprite called inside of their creation function and stored inside of their type instance. However, this isn't working. Why not? |
| ||
Can you define "isn't working" a little further? |
| ||
right, I should know that by now. I get 'entity does not exist' the next time I try to use the sprite (in the same function, so the type instance is still selected). |
| ||
Send the value of the type field which loads the entity to the debuglog see if it's actually loading correctly (i.e. non zero). The entity may not be in the correct directory. Other than that you'll probably have to show us the function. |
| ||
Or, post some code of the loading of the sprite, into the type collection. |
| ||
Okay, I got the loading working right... Now, is there a way to set what colour is used to mask a sprite? I'm pretty sure that maskImage doesn't work, but I can't think of anything else. |
| ||
You can't change the mask color of a texture (it is 0,0,0) but you can use alpha transparency instead of masked transparency to mask out parts of the image which are not black. |
| ||
Direct3D allows you to pick any colour as the mask, but mark hasnt enabled the option. |
| ||
Yes, you can pick a mask colour. I done some functions for that :) http://www.blitzbasic.com/Community/posts.php?topic=33427 The mask color is really just alpha values written to the texture, where there is a color (0,0,0). Any pixel/texel having an alpha value below 128, will be masked. Go here.... |
| ||
Oh heck, I'll just make their legs slightly brighter than black. Thanks for the help though, I've got those functions saved. Um, how can I camerapick a sprite now? It's not returning anything when I try to. If MouseDown(1) bset.buttonSet = Last buttonSet If MouseDown(2) Or RectsOverlap(MouseX(),MouseY(),1,1,bset\x,bset\y,bset\w,bset\h) Then Goto skipselection if show_bigwindow = true if RectsOverlap(MouseX(),MouseY(),1,1,200,60,400,340) Then Goto skipselection endif CameraPick cam,MouseX(),MouseY() If Not PickedEntity() <> 0 Then Goto skipselection e.entity = Object.entity(EntityName(PickedEntity())) select order_give case move action = move_settler end select selected_Type = e\entityForm selected_ID = e\parent_ID Select selected_Type Case TradePost fortPicked = selected_id boundingbox = pickedentity() fort.fort = Object.fort(selected_ID) insert fort.fort after last fort action = open_fortWindow case settler boundingbox = pickedentity() s.settler = object.settler(selected_id) insert s.settler after last settler action = open_settlerwindow End Select |
| ||
Could be wrong but I don't think sprites are pickable. |
| ||
gah NOO!! I'll have to use camproject then. |
| ||
oh, forget that. I'll just make an invisible cube that's pickable. |