@fs2020 Could you give us some info about what gives you trouble about adding the effects to your game?
It should be pretty simple, just load the effects you need when you intitialize your game:
#include "inc_gpup.agc" // include the particle addon
gpup_init() // initialize the particle system (this will load the particle geometry , the noise textures, etc)
myEffect = gpup_loadEffect("effectname", x position, y position, z position, scale) // load an effect and position it
gpup_emitterActive( myEffect, gpup_active ) // let the effect emit particles. This will basically turn the emitter on. You can ofcourse use this command at any time to turn an effect on or off.
and then in your game loop:
gpup_update() // update the particles
That's it.
If it's a triggered effect like an explosion that doesn't emit continuously, then you can use
gpup_emitterFire(myEffect) to trigger it to fire the amount of particles you have specified in the editor.
Your game might ofcourse need several explosions at different places, for that you can reuse one effect and easily reposition it without moving already emitted particles from older explosions:
gpup_setGlobalPivot( myEffect, x position, y position, z position )
Just make sure the emit count is set low enough that you have enough particles for several simultanious explosions and you are set.
Here is the complete code of an AppGameKit program that loads and displays an effect created in the editor:
#option_explicit
myEffect1 as integer
// Initialie AGK rendering
init()
// Include the particle addon
#include "inc_gpup.agc"
// Initialize the particle system
gpup_init()
myEffect1 = gpup_loadEffect("animrunner2", 0, 0, 0, 1.0) // load an effect at position 0,0,0
gpup_emitterActive( myEffect1, gpup_active) // activate the effect
// Main loop
do
Print(str(ScreenFPS()) )
Print("Active effects: "+str(gpup_settings.activeEffects))
// Update the particle system. Call this every refresh.
gpup_update()
Sync()
if ( GetRawKeyState(27) ) then exit
loop
end
function init()
sx as integer
sy as integer
sx = GetMaxDeviceWidth()*0.7
sy = GetMaxDeviceHeight()*0.7
SetErrorMode(2)
SetWindowTitle( "Runtime Demo" )
SetAntialiasMode( 1 )
SetWindowSize( sx, sy, 0)
SetVirtualResolution(sx, sy)
UseNewDefaultFonts( 1 )
SetPrintSize( 20 )
SetGenerateMipmaps( 1 )
SetSyncRate( 0, 0 )
setcamerarange(1, 0.01, 650)
SetClearColor( 55,88,100 )
SetCameraPosition( 1, 0, 0.8, -4.5 )
SetCameraLookAt(1, 0, 0.5, 0, 0)
endfunction
Most of that code is just the standard AppGameKit initialization. Only the few commands I described above are particle related.
@haliop787
Some 2D helper functions are in the new update. It's ready to be sent out, but unfortunately the Vulkan/Metal stuff causes some issues with the effects in iOS exports (looks like a precision issue), so that needs to be ironed out first. On the bright side, hopefully future users using custom shaders and iOS targets will not have to deal with the same issues.