creditsui.js 1.1 KB

12345678910111213141516171819202122232425262728293031
  1. import gsap from "gsap"
  2. import { closeMainMenuUI, openMainMenuUI } from "./mainmenuui"
  3. export function creditsUI(game, stageData) {
  4. document.getElementById("credits-container").addEventListener('click', () => {
  5. hideCreditsUI(game, stageData)
  6. })
  7. document.getElementById("credits-back-button").addEventListener('click', () => {
  8. hideCreditsUI(game, stageData)
  9. })
  10. document.getElementById("credits-panel").addEventListener('click', event => {
  11. event.stopPropagation()
  12. })
  13. }
  14. export function showCreditsUI(game, stageData) {
  15. document.getElementById("credits-container").style.display = "flex"
  16. const panel = document.getElementById("credits-panel")
  17. gsap.to(panel, {x: 0, duration: 0.8, onComplete: () => {
  18. }})
  19. closeMainMenuUI(game, stageData)
  20. }
  21. export function hideCreditsUI(game, stageData) {
  22. const panel = document.getElementById("credits-panel")
  23. gsap.to(panel, {x: -1024, duration: 0.8, onComplete: () => {
  24. document.getElementById("credits-container").style.display = "none"
  25. }})
  26. openMainMenuUI(game, stageData)
  27. }