I have been getting problems with some code that's called to produce some particle emitters at the end of game
so I mocked up the below code to test looks fine under windows but in android its all out of wack
Adding a setdisplayaspect of -1 helped a little as I had it all working except for a snippet at the bottom
now its not even doing that.
Do I need to setdisplayaspect after particles or a render image or something I'm not sure
#constant maxNumberFireworks=8
#constant speed=1.0
#constant frequency=3.14
#constant maxWidth=800
#constant maxHeight=600
SetWindowTitle( "fireworks" )
SetWindowSize( maxWidth, MaxHeight, 0 )
// set display properties
SetVirtualResolution( maxWidth, MaxHeight )
SetOrientationAllowed( 0, 0, 1, 1 )
SetDisplayAspect( -1 )
UseNewDefaultFonts( 1 ) // since version 2.0.20 we can use nicer default fonts
SetVSync(1)
SetPrintSize(50)
do
if GetPointerPressed()
congratulations("Congratulations tap screen to exit")
endif
Print("tap screen for fireworks")
Sync()
loop
end
function setupFirework(obj as integer)
CreateParticles(obj,100,100) //id,x,y
SetParticlesSize(obj,2) //pixel size of particles
SetParticlesLife(obj,5) //sets the length of 5 seconds the particles live
SetParticlesMax(obj,75) //max number of particles set to 75 f
`SetParticlesActive(1,0)
AddParticlesForce(obj,1,4,0,15) //The time a particle has to wait before forces apply
SetParticlesFrequency(obj,100) //Sets the frequency of new particle generation
SetParticlesVelocityRange(obj,2,4) //velocity factor of particles ranging from min of 2 to 4
SetParticlesColorInterpolation(obj,0) //1 smooth 0 none
SetParticlesVisible( obj, 0 ) //hide particles when they first created so as timer can be used
endfunction
function doFirework (obj as integer)
SetParticlesVisible( obj, 1 ) //make particle visible
SetParticlesPosition(obj,Random(100,GetVirtualWidth()-100),Random(100,GetVirtualHeight()-100))
ResetParticleCount(obj)
AddParticlesColorKeyFrame(obj,1,Random(100,250),Random(100,250),Random(100,250),255)
AddParticlesColorKeyFrame(obj,2,Random(100,200),Random(100,200),Random(100,200),200)
AddParticlesColorKeyFrame(obj,4,Random(50,100),Random(50,100),Random(50,100),25)
endfunction
function congratulations (text as String)
dim fireFlag [maxNumberFireworks] as integer //variable to hold the present particle emmitter
dim fireSound [maxNumberFireworks] as integer
SetSoundSystemVolume(100)
for num = 1 to maxNumberFireworks
setupFirework(num)
fireSound[num]=LoadSound("firework.wav")
SetSoundInstanceVolume(fireSound[num],75)
fireFlag[num]=0
next num
fireBg = createsprite(0)
setspritesize(fireBg,GetVirtualWidth(),GetVirtualHeight())
SetSpriteColor(fireBg,0,0,0,8)
Print(text)
//Print("TapScreen to continue")
//myText=CreateText("TextFun")
//SetTextColor(myText,255,255,255,255)
render() //draw all 2d and 3d to screen
myFireworkBackImage=GetImage(0,0,maxWidth,maxHeight)
MyFireworkBackSprite=CreateSprite(MyFireworkBackImage)
SetSpriteSize(MyFireworkBackSprite,maxWidth,maxHeight)
SetSpriteDepth(MyFireworkBackSprite,10000)
SetSpriteColorAlpha(MyFireworkBackSprite,10)
SetSpritePositionByOffset(MyFireworkBackSprite,maxWidth/2,maxHeight/2)
renderImg=CreateRenderImage (GetVirtualWidth(),GetVirtualHeight(),0,0)
ClearScreen()
createsprite(350,renderImg)
repeat
SetRenderToImage (renderImg,0)
createsprite(350,renderImg)
DrawSprite(MyFireworkBackSprite)
DrawSprite(fireBg)
for num=1 to maxNumberFireworks
if (fireFlag[num]=0) and random(1,100)<5 //a 5 percent chance of that particle being emitted
doFirework(num):playSound(fireSound[num])
fireFlag[num]=1
UpdateParticles(num,0)
endif
if GetParticlesMaxReached(num)=1 //and GetParticlesMaxReached(num+100)=1
fireFlag[num]=0
endif
next num
Update(0)
Render()
setrendertoscreen ()
SetSpriteImage(350,renderImg)
Update(0)
Render()
swap()
until GetPointerPressed ( ) = 1
DeleteSprite(MyFireworkBackSprite)
DeleteImage(MyFireworkBackImage)
for num = 1 to maxNumberFireworks
DeleteParticles(num)
DeleteSound (fireSound[num])
next
SetRenderToImage (renderImg,0)
drawSprite(fireBg) //pastes a black sprite to buffer and screen
Update(0)
Render()
swap()
DeleteSprite(350)
DeleteSprite(fireBg)
setrendertoscreen ()
DeleteImage(renderImg)
endfunction
fubar