Seite 1 von 1

Von Total Transparent zu Voll Sichtbar

Verfasst: 27.07.2014 21:47
von NeoRon
Hallo liebe PB Community,

ich möchte einen GameOver Bild Sprite über den Spielescreen von 0 Tranmsparenz auf 100% voll Sichtbar einblenden.

Ich weis aber nicht wie ich das tue.

Ob über den DrawingMode und/oder DisplayTransparentSprite.
Das ich mit ner for next schleife hochzähle.

Ka so richtig vllt könnt ihr mir da weierhelfen.

Danke
Grüße

Re: Von Total Transparent zu Voll Sichtbar

Verfasst: 27.07.2014 22:28
von Derren
So in etwa, das musst du nur an geeignet Stelle in deinen Code einfügen (im EventLoop)

Code: Alles auswählen

  If gameover=#True
    If intensity < 255
      intensity+1
    Endif    
    DisplayTransparentSprite(#GameOver, 0, 0, intensity)
  Endif



edit: Hab hier mal auf die Schnelle ein lauffähiges Beispiel zusammen geschustert. Schlecht formatierter Code und nicht kommentiert, aber soll auch wirklich nur ein kurzes Beispiel sein.
Mit Leertaste wird der Game Over Zustand aktiviert und deaktiviert (reset).

Code: Alles auswählen

InitSprite()
InitKeyboard()

Define intensity.f

LoadFont(0,"Arial",60)
Define text.s = "GAME OVER"

OpenWindow(0,0,0,640,480,"MyGame",#PB_Window_SystemMenu|#PB_Window_ScreenCentered)
OpenWindowedScreen(WindowID(0),0,0,640,480)

CreateSprite(0,640,480)
StartDrawing(SpriteOutput(0))
Box(0,0,640,480,RGB(Random(255), Random(255), Random(255)))
DrawingFont(FontID(0))
DrawingMode(#PB_2DDrawing_Transparent )
DrawText(320-TextWidth(text)/2, 240-TextHeight(text)/2, text)
StopDrawing()

CreateSprite(1,640,480)
StartDrawing(SpriteOutput(1))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))
Circle(Random(640),Random(480), Random(100),RGB(Random(255), Random(255), Random(255)))

StopDrawing()

Repeat 
	ExamineKeyboard()
	event=WaitWindowEvent(10)
	
	ClearScreen(0)
	
	
	DisplaySprite(1,0,0)
	
	
	If gameover=#True
		If intensity >= 254
			intensity=255
		Else 
			intensity+2
		EndIf   
		DisplayTransparentSprite(0, 0, 0, intensity)
	EndIf
	
	If KeyboardReleased(#PB_Key_Space)
		If gameover=#True
			gameover=#False
			intensity=0
			SetWindowTitle(0, "MyGame")
		Else
			gameover=#True
			SetWindowTitle(0, "MyGame [GAME OVER]")
		EndIf 
	EndIf 
	
	
	FlipBuffers()
Until event = #PB_Event_CloseWindow 

Re: Von Total Transparent zu Voll Sichtbar

Verfasst: 27.07.2014 22:51
von NeoRon
Hi Danke^^

Er meldet bei mir DisplayTransparentSprite falsche zahl an Parameter.

Re: Von Total Transparent zu Voll Sichtbar

Verfasst: 27.07.2014 23:54
von Kiffi
NeoRon hat geschrieben:Er meldet bei mir DisplayTransparentSprite falsche zahl an Parameter.
Zeit für ein Update?
PB-Historie hat geschrieben:17th September 2013 : Version 5.20 LTS

- Added: 'Color' and 'Intensity' parameter to DisplayTransparentSprite()

Re: Von Total Transparent zu Voll Sichtbar

Verfasst: 28.07.2014 15:43
von NeoRon
Danke Leute.

Lag an der alten Version. Habs geupdated.