I would appreciate some advice on how to overcome the issue that is described in the comments in the code below:
ProcedureTForm1.FormCreate(Sender:TObject);Vari:Integer;BeginForm1.WindowState:=wsMaximized;//CreateNoOfSprites; the speed of each is chosen at random, X and Y positions likewise//Thisapplicationsimulatestherandommovementofsingleatoms.Collisionswiththewallsarehandledexplicitly.//Can theCollisionManagercomponentbeusedtohandlecollisoonbetweenatoms?Iassumethatitcanbut//Ihavemadevariousattemptsatdoingthiswithoutsuccess-fromlistoutofboundstoaccessviolationerrors//Ihaveremovedmyvariousunssuccesfulattemptsfromthecodethatfollows.WhyhaveInotattemptedtorelyonDesigntimeHUDSprites?//Theanswertothisquestionisthatthenumberofspritesinthesimulationdoesnotmakeitpracticaltodothis.Fori:=0ToNoOfSpritesDoBeginSpriteArray[i].GLHudSprite:=TGLHudSprite.Create(Form1);SpriteArray[i].GLHudSprite.Width:=4;SpriteArray[i].GLHudSprite.Height:=4;//Needtocreateabehaviouritemindex0atruntimebut//sofarIhavebeenunsuccessful-IamunabletogettogripswithTXCollections!TGLBCollision(SpriteArray[i].GLHudSprite.Behaviours[0]).Manager:=GLCollisionManager1;SpriteArray[i].GLHudSprite.Material.BlendingMode:=bmAdditive;SpriteArray[i].GLHudSprite.Material.Texture.TextureMode:=tmModulate;SpriteArray[i].GLHudSprite.Material.Texture.Disabled:=True;SpriteArray[i].GLHudSprite.Material.FrontProperties.Emission.Red:=65000;SpriteArray[i].GLHudSprite.Material.FrontProperties.Emission.Blue:=0;SpriteArray[i].GLHudSprite.Material.FrontProperties.Emission.Green:=0;SpriteArray[i].GLHudSprite.Material.FrontProperties.Diffuse.Alpha:=1;SpriteArray[i].GLHudSprite.Material.FrontProperties.Diffuse.Red:=0;SpriteArray[i].GLHudSprite.Material.FrontProperties.Diffuse.Green:=0;SpriteArray[i].GLHudSprite.Material.FrontProperties.Diffuse.Blue:=0;SpriteArray[i].GLHudSprite.Position.X:=Random(Screen.Width);SpriteArray[i].GLHudSprite.Position.Y:=Random(Screen.Height);SpriteArray[i].SpeedX:=Random(200);SpriteArray[i].SpeedY:=Random(200);If(iMod2=0)ThenBeginSpriteArray[i].DirectionX:=-1;SpriteArray[i].DirectionY:=1;EndElseBeginSpriteArray[i].DirectionX:=1;SpriteArray[i].DirectionY:=-1;End;SpriteArray[i].GLHudSprite.Parent:=GLDummyCube1;End;End;
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I would appreciate some advice on how to overcome the issue that is described in the comments in the code below:
Hi!
Have you managed to make to sprites collide if you create them at design time?
I do like this to create collision behaviour at runtime:
I never tried on a sprite though.
Last edit: Daniel 2021-09-06