Von Total Transparent zu Voll Sichtbar

Anfängerfragen zum Programmieren mit PureBasic.
Benutzeravatar
NeoRon
Beiträge: 67
Registriert: 22.03.2013 18:56

Von Total Transparent zu Voll Sichtbar

Beitrag 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
The World is Cyber
Derren
Beiträge: 558
Registriert: 23.07.2011 02:08

Re: Von Total Transparent zu Voll Sichtbar

Beitrag 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 
Signatur und so
Benutzeravatar
NeoRon
Beiträge: 67
Registriert: 22.03.2013 18:56

Re: Von Total Transparent zu Voll Sichtbar

Beitrag von NeoRon »

Hi Danke^^

Er meldet bei mir DisplayTransparentSprite falsche zahl an Parameter.
The World is Cyber
Benutzeravatar
Kiffi
Beiträge: 10714
Registriert: 08.09.2004 08:21
Wohnort: Amphibios 9

Re: Von Total Transparent zu Voll Sichtbar

Beitrag 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()
a²+b²=mc²
Benutzeravatar
NeoRon
Beiträge: 67
Registriert: 22.03.2013 18:56

Re: Von Total Transparent zu Voll Sichtbar

Beitrag von NeoRon »

Danke Leute.

Lag an der alten Version. Habs geupdated.
The World is Cyber
Antworten