Quote Originally Posted by Robert Kosek
Andreas!! The error is that you aren't creating an imagelist! Searching a nil pointer for a string is a painful crash. Goodness, there isn't even a parameter to pass one to the particle manager's constructor. I hope you've got an updated copy on hand. :lol:
Me ?

Hehe, anyway in the particle demo i have the following (not shure its changed alot since the april version either)
Code:
 Images:= TPHXImageList.Create;
  Images.LoadImage('Circle.png');
  Images.LoadImage('Spark.png');
  Images.LoadImage('Fire.png');


  ParticleManager:= TPHXParticleManager.Create;
  ParticleManager.Images:= Images;
There, imagelist assigned to the particle manager and ready

And to note, all components that uses imagelists, fonts or any other resource requires the user to bind the list to the component, so you may run into the same thing again.

Quote Originally Posted by Robert Kosek
Code:
unit Main;

{$IFDEF FPC}
{$mode objfpc}{$H+}
{$ENDIF}    

interface

uses
  Classes, SysUtils,
  phxBase,
  phxImages,
  phxParticles,
  phxInput,
  phxTimer,
  phxMath,
  phxClasses,
  phxLogger,
  phxScreen;

const
  Gravity: TVector2f = (x: 0; y: -9.81); // Gravitic Constant of Earth in M/Sec^2 (Velocity)


procedure MainLoop;

implementation

//------------------------------------------------------------------------------
procedure MainLoop;
var Screen: TPHXScreen;
    Particles: TPHXParticleManager;
    Mouse: TPHXMouse;
    Keyboard: TPHXKeyboard;
    Timer: TPHXTimer;

    i,l: Word;
begin
  // Get the window
  Screen    := TPHXScreen.getInstance;
  Particles := TPHXParticleManager.Create;
  Mouse     := TPHXMouse.Create;
  Timer     := TPHXTimer.Create;
  Keyboard  := TPHXKeyboard.Create;

  Screen.VSync := True;
  Screen.DepthBits := 32;
  // Open the window
  if not Screen.Open('Gravity Bombs', -1, -1, 800, 600) then begin
    TPHXLogger.getInstance.Log(logSevere, 'Main', 'Unable to initialize form.');
    Exit;
  end;

//  with Particles.Effects.Add do begin
//    TPHXLogger.getInstance.Log(logInfo, 'Main', 'Loading comet particle...');
//    LoadFromFile('comet.phxpar');
//    Name := 'Comet';
//    GrowthMin := -16;
//    GrowthMax := -16;
//    Texture := 'particle.png';
//  end;

  if not Assigned(Particles.Images) then begin
    Particles.Images := TPHXImageList.Create;
    TPHXLogger.getInstance.Log(logWarning, 'Main', 'Imagelist is nil; initializing.');
  end;
  Particles.Images.LoadImage('particle.png').UpdatePatterns;

  l := 0;

  with Particles.Effects.Add do begin
    Name := 'Comet';
    Quota := 500;
    EmissionRate:= 100;
    Texture := 'particle.png';
    Blending := bmAdd;
    DurationMin := 0.50;
    DurationMax := 0.75;
    Direction := -90;
    SpreadMin := 360;
    SpreadMax := 360;
    VelocityMin := 72;
    VelocityMax := 84;
    TimeToLiveMin := 0.5;
    TimeToLiveMax := 0.5;
    SizeMin := 32;
    SizeMax := 32;
    GrowthMin := -12;
    GrowthMax := -16;
    NumColors := 3;
    Colors[0] := Color4f(0.7,0.8,1.0,0.6);
    Colors[1] := Color4f(0.6,0.7,0.9,0.6);
    Colors[2] := Color4f(0.1,0.2,0.5,0.6);
  end;

  Randomize;

  repeat
    Timer.Update;
    Mouse.Update;
    Keyboard.Update;

    if Random&#40;200&#41; <100> 0 then
      for I &#58;= 0 to Particles.Count - 1 do
        with Particles.Systems&#91;i&#93; do begin
          Position &#58;= VectorSub&#40;Position,VectorMul&#40;Gravity,Timer.FrameTime&#41;&#41;;
          if Position.Y > 650 then
            Particles.RemoveSystem&#40;Particles.Systems&#91;i&#93;&#41;;
        end;

    Particles.Move&#40;Timer.FrameTime&#41;;

    if l <> Particles.Count then begin
      l &#58;= particles.Count;
      Screen.Title &#58;= Format&#40;'Gravity Bombs &#91;%d active particle systems&#93;',&#91;l&#93;&#41;;
    end;

    // Clear the window
    Screen.Clear;

    Particles.Render;

    // Flip the buffers
    Screen.Flip;
  until &#40;Screen.Visible = False&#41;;

  Particles.Images.Free;
  Particles.Free;
  Keyboard.Free;
  Mouse.Free;
  Timer.Free;
  Screen.Free;
end;

end.
I've changed how the particle systems is managed by the manager, uses a standard TList now instead, should help on that error.


Oh, and theres no need to call UpdatePatterns when loading an image, it's done automatically Only needed if you change the patterns manually!