Hello jfk,
I'm referring here to your nice particle code you have posted in the code archive : http://www.blitzbasic.com/codearcs/codearcs.php?code=577
I need to parent the sprite to an entity, so to have a fired bullet with some smoke attached to it.
To do so, I've modified your CSP_LaunchParticle function in a way it accepts an entity where to attach the sprite to:
Then in the function:
The problem is that the prog crashes after some call to the particle function. If you want to reproduce the error, try this:
On my system, it crashes after the call to "CSP_LaunchParticle(0, + all the params to make fire)", the statement right after the end of the loop.
I do the for..next loop here 100 times, to force the bug to come soon. Usually I do not use any for..next, but then the bug comes later.
If I do not parent the sprite to any entity, it works fine.
I have also tryed to parent the sprite to a pivot, and moved the entityparent statement right after the statement "CSPfire_handle(i)=CSPfire(i)", but it crashes the same. No fun also if I use simply "CSPfire(i)=CreateSprite(ent)"
Do you have any though on why this happens ? Apparently, there's no problem to parent a sprite to an entity; I've dig a bit in the function, but I don't get where is the problem. Sometime I have 'Entity does not exist' error on the statement "ShowEntity CSPfire(i)", sometime I have different errors, but all related to the "CSPfire(i)" sprite.
How would you do, if you want to parent the sprite to an entity in this particular case ?
Any help would be appreciated.
Sergio.
I'm referring here to your nice particle code you have posted in the code archive : http://www.blitzbasic.com/codearcs/codearcs.php?code=577
I need to parent the sprite to an entity, so to have a fired bullet with some smoke attached to it.
To do so, I've modified your CSP_LaunchParticle function in a way it accepts an entity where to attach the sprite to:
;see first parameter Function CSP_LaunchParticle(ent = 0,fx=0, texture, nof_sprite=2, x#=0, y#=0, z#=0, min_size#=1, max_size#=3, speed#=0.1, livespan=3,blend=3,rand_rot=1,lift#=0,alpha#=1.0)
Then in the function:
If CSPfire(i)=0 Then ; using this sprite the first time CSPfire(i)=CreateSprite() EntityParent CSPfire(i),ent ;parent the sprite to the entity ent CSPfire_handle(i)=CSPfire(i) EndIf ;the rest is unchanged ;.. ;..
The problem is that the prog crashes after some call to the particle function. If you want to reproduce the error, try this:
ent = createcube() for n = 1 to 100 CSP_LaunchParticle(ent, + all the params to make smoke) next CSP_LaunchParticle(0, + all the params to make fire)
On my system, it crashes after the call to "CSP_LaunchParticle(0, + all the params to make fire)", the statement right after the end of the loop.
I do the for..next loop here 100 times, to force the bug to come soon. Usually I do not use any for..next, but then the bug comes later.
If I do not parent the sprite to any entity, it works fine.
I have also tryed to parent the sprite to a pivot, and moved the entityparent statement right after the statement "CSPfire_handle(i)=CSPfire(i)", but it crashes the same. No fun also if I use simply "CSPfire(i)=CreateSprite(ent)"
Do you have any though on why this happens ? Apparently, there's no problem to parent a sprite to an entity; I've dig a bit in the function, but I don't get where is the problem. Sometime I have 'Entity does not exist' error on the statement "ShowEntity CSPfire(i)", sometime I have different errors, but all related to the "CSPfire(i)" sprite.
How would you do, if you want to parent the sprite to an entity in this particular case ?
Any help would be appreciated.
Sergio.