Sprite Candy and Z-Order

Blitz3D Forums/Blitz3D Userlibs/Sprite Candy and Z-Order

Hhmmm strange. I posted the below code about 2 hours ago, but it was deleted. Anyway I will post it again for anyone else who wants a solution to this problem...

Graphics3D 800,600,0

Include "sprite candy.bb"

camera=CreateCamera()
light=CreateLight()
LightColor light,50,50,50

cube=CreateCube()
PositionEntity cube,0,0,5

Texture% = CreateTexture(256,256,1+256)
SetBuffer TextureBuffer(texture)
Color 0,0,250
Rect 0,0,256,256,1
Color 0,0,200
Rect 0,0,128,128,1
Rect 128,128,128,128,1
SetBuffer BackBuffer()
BackHUD% = HUD_Create (camera)
FrontHUD% = HUD_Create (camera)
Resource%    = HUD_LoadMemoryResource (Texture) 
BackImageLayer%  = HUD_CreateLayer        (BackHUD, Resource)
FrontImageLayer%  = HUD_CreateLayer        (FrontHUD%, Resource)
Texture          = HUD_GetTextureHandle   (Resource) 

; CREATED AN IMAGE THAT FITS ENTIRE SCREEN (BACK LAYER)
Image1%          = HUD_CreateImage (BackImageLayer, 0,0, 0,0,800,600, "CENTER","CENTER")
HUD_SetObjectScale Image1,2,2
HUD_SetObjectAlpha Image1,.5

; APPLY SOME EFFECTS
HUD_FX_SteadyScale Image1, 2,2,2*1.2,2*1.2,4000
HUD_FX_Ripple      Image1, 5,20,15

; NOW SOME OBJECTS INFRONT (FRONT LAYER)
ShapeHandle% =  HUD_CreateShape (  FrontImageLayer%,  "HOLLOWSTAR" ,  6,  60,  400,  300,  400,400 ) 

; APPLY SOME EFFECTS
EffectHandle% =  HUD_FX_Rotate (  ShapeHandle%,  360,  True, 7000, 0 ) 
EffectHandle% =  HUD_FX_SteadyScale (  ShapeHandle%,  0.5,  0.5,    1.5,  1.5, 3000,0) 
HUD_SetObjectColor (  ShapeHandle%,  0,  255,  255) 
HUD_SetObjectShadow (  ShapeHandle%,  True,  10  ) 

CameraClsMode camera,False,True

While Not KeyDown(1)
	If HUD_CountEffects(ShapeHandle,"ROTATE")=0 Then EffectHandle% =  HUD_FX_Rotate (  ShapeHandle%,  360,  True, 7000, 0 ) 
	If HUD_CountEffects(ShapeHandle,"COLORFADE")=0 Then 
		EffectHandle% =  HUD_FX_ColorFade (  ShapeHandle%,    255,255,0,    3000,0 ) 
		EffectHandle% = HUD_FX_ColorFade (  ShapeHandle%,    0,255,255,    3000,3000 ) 
		
	EndIf
	HUD_SetVisibility(BackHud,True)
	HideEntity cube
	HUD_Update()
	RenderWorld()
	HUD_SetVisibility(BackHud,False)
	ShowEntity cube
	TurnEntity cube,0.5,0.5,0.5
	RenderWorld 0
	Flip
Wend


Cheers,


Unc