Centro RPG Maker

Centro de Outras Engines => Tutoriais e Sistemas (Outras Engines) => Tópico iniciado por: makergame2000 online 02/03/2020 às 13:07

Título: [AppGameKit] Fade In & Out
Enviado por: makergame2000 online 02/03/2020 às 13:07
Fade In e Out


Sistema de fade para vários sprites ao mesmo tempo em mapa.
Instruções: Fazer include do código, utilizar FadeStart(id, tipo) com o id do sprite e o tipo de fade (1 - In, 2 - Out), chamar a função Fade em cima do Sync()

Include

global FadeOutList as integer[]
global FadeInList as integer[]

function FadeStart(id as integer,dir as integer) // 0 - Out, 1 + In
if dir = 0
if not FadeOutList.find(id) = -1
FadeOutList.remove(FadeOutList.find(id))
endif
FadeOutList.insert(id)
else
if not FadeInList.find(id) = -1
FadeInList.remove(FadeInList.find(id))
endif
FadeInList.insert(id)
endif
endfunction

function Fade()
for i = 0 to FadeOutList.length
SetSpriteColorAlpha(FadeOutList[i], GetSpriteColorAlpha(FadeOutList[i]) - 15)
if GetSpriteColorAlpha(FadeOutList[i]) = 0
FadeOutList.remove(i)
endif
next i

for i = 0 to FadeInList.length
SetSpriteColorAlpha(FadeInList[i], GetSpriteColorAlpha(FadeInList[i]) + 15)
if GetSpriteColorAlpha(FadeInList[i]) = 255
FadeInList.remove(i)
endif
next i
endfunction


Exemplo de uso
(https://i.imgur.com/MwKay3z.gif)

#include "FadeInOut.agc"

SetErrorMode(2)
SetWindowTitle( "FadeInOut" )
SetWindowSize( 1024, 768, 0 )
SetWindowAllowResize( 1 )
SetVirtualResolution( 1024, 768 )
SetOrientationAllowed( 1, 1, 1, 1 )
SetSyncRate( 30, 0 )
SetScissor( 0,0,0,0 )
UseNewDefaultFonts( 1 )

CreateSprite(1, 0)
SetSpritePosition(1, 150, 150)
SetSpriteSize(1, 100, 100)

CreateSprite(2, 0)
SetSpritePosition(2, 20, 20)
SetSpriteSize(2, 100, 100)
SetSpriteColorAlpha(2, 0)


for i = 1 to 20
CreateSprite(i + 100, 0)
SetSpritePosition(i + 100, 20 + (i*25), 400)
SetSpriteSize(i + 100, 20, 20)

next i

do
    if GetRawKeyPressed(69)
FadeStart(1, 0)
FadeStart(2, 1)

for i = 101 to 120
FadeStart(i, 0)
next i
    endif
   

    Fade()
    Sync()
loop