Fire effect quits working doring 2nd level load.
Blitz3D Forums/Blitz3D Programming/Fire effect quits working doring 2nd level load.
| ||
Hi, I'm trying the "fire effect" code in the 3d examples. I got it to work on the first level of a 3 level game. My game switches via "goto" statements. When the second level is loading it generates the error "the entity does not exist." It just existed in the first level and I am at a loss to understand why it does not work or how to fix it so it does work. The code I use follows. Anyone have the same experience or recognize how to fix it? The error occurs here, at the> Add_Flame(Entityx... part. It says: Entity does not exist. It worked/existed in the first level but not in the rests of the program. ;Update all fires Function Update_Fires() For a.fire=Each fire Add_Flame(EntityX(a\piv),EntityY(a\piv),EntityZ(a\piv),Rnd(1,4),.04,a\dx,a\dy,a\dz) Next Update_Flames() End Function Global flame01=LoadSprite("gameart\base.bmp") ;Each Flame of the fire Type flame Field ent Field ang# Field size# Field alph# Field dis# Field dx#, dy#, dz# End Type ;The fire itself Type fire Field piv ; Direction Field dx#, dy#, dz# End Type ;Add a flame to the fire Function Add_flame(x#,y#,z#,size#=1,dis#=.016,dx#=0,dy#=0.3,dz#=0) a.flame=New flame a\ent=CopyEntity(flame01) PositionEntity a\ent,x,y,z a\alph=1 a\size=size a\dis=dis a\ang=Rnd(360) ScaleSprite a\ent,a\size,a\size EntityColor a\ent,Rnd(150,255),Rnd(0,100),0 a\dx=dx a\dy=dy a\dz=dz End Function ;Update flames Function Update_flames() For a.flame=Each flame If a\alph>0.01 Then a\alph=a\alph-a\dis EntityAlpha a\ent,a\alph RotateSprite a\ent,a\ang a\ang=a\ang+.2 MoveEntity a\ent,a\dx,a\dy,a\dz Else FreeEntity a\ent Delete a End If Next End Function ;Erase all flames Function Erase_flames() For a.flame=Each flame If a\ent<>0 Then FreeEntity a\ent Next Delete Each flame End Function ;Update all fires Function Update_Fires() For a.fire=Each fire Add_Flame(EntityX(a\piv),EntityY(a\piv),EntityZ(a\piv),Rnd(1,4),.04,a\dx,a\dy,a\dz) Next Update_Flames() End Function ;Add a fire to the scene Function Add_Fire.fire(x#,y#,z#,dx#=0,dy#=.23,dz#=0) a.fire=New fire a\piv=CreatePivot() PositionEntity a\piv,x,y,z a\dx=dx:a\dy=dy:a\dz=dz Return a End Function tfire.fire=Add_Fire(0,0,0) ;in main loop Update_Fires() ;remove after 25 iterations se = se + 1 If se >= 25 Then HideEntity flame01 ;erase_Flames HideEntity Exp1 TranslateEntity tfire\piv,0,5000,0 End If ;locate the fire at target collision PositionEntity tfire\piv,CollisionX#(bullet(q),1),CollisionY#(bullet(q),1),CollisionZ#(bullet(q),1) |