sprite in a type?

Blitz3D Forums/Blitz3D Programming/sprite in a type?

Picklesworth(Posted 2004) [#1]
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?


Warren(Posted 2004) [#2]
Can you define "isn't working" a little further?


Picklesworth(Posted 2004) [#3]
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).


Stevie G(Posted 2004) [#4]
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.


Ross C(Posted 2004) [#5]
Or, post some code of the loading of the sprite, into the type collection.


Picklesworth(Posted 2004) [#6]
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.


jhocking(Posted 2004) [#7]
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.


smilertoo(Posted 2004) [#8]
Direct3D allows you to pick any colour as the mask, but mark hasnt enabled the option.


Ross C(Posted 2004) [#9]
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....


Picklesworth(Posted 2004) [#10]
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



big10p(Posted 2004) [#11]
Could be wrong but I don't think sprites are pickable.


Picklesworth(Posted 2004) [#12]
gah NOO!! I'll have to use camproject then.


Picklesworth(Posted 2004) [#13]
oh, forget that. I'll just make an invisible cube that's pickable.