It is currently Wed Nov 20, 2019 3:24 am

All times are UTC + 1 hour




Post new topic Reply to topic  [ 4 posts ] 
Author Message
 Post subject: Transparency not working
PostPosted: Thu Oct 10, 2019 11:05 am 
Offline
User
User

Joined: Sat Apr 13, 2019 12:17 pm
Posts: 43
Hi I've been experimenting with a bit of code and have found that the transparency isn't working pleas see attached code and plane.png file. sorry couldn't upload the plane.png file but the transparency is working on it. just not in my PB program as below.
thanks for reading .
Code:
InitSprite()
UsePNGImageDecoder()
InitKeyboard()
OpenWindow(0,0,0,1366,768,"Paul's program! Press Return To Exit!")
OpenWindowedScreen(WindowID(0),0,0,1366,768)
SetWindowColor(0,#Black)
ClearScreen(#Black)
x = -179
y = 400
pf = LoadImage(1,"plane.png")

  Loopy:
 
 
  StartDrawing(WindowOutput(0))
  DrawText(10,10,"hello world")
 
  DrawImage(pf,x,y)
  x=x+10
  If x >= 1366
    x= -179
    EndIf
    StopDrawing()
    FlipBuffers()
  WindowEvent()
  ExamineKeyboard()
  If  KeyboardPushed(#PB_Key_Return)
    End
  EndIf
  If  KeyboardPushed(#PB_Key_W)
    y=y-10
  EndIf
 
   If  KeyboardPushed(#PB_Key_S)
    y=y+10
  EndIf
 Goto loopy


Top
 Profile  
Reply with quote  
 Post subject: Re: Transparency not working
PostPosted: Thu Oct 10, 2019 11:25 am 
Offline
Enthusiast
Enthusiast
User avatar

Joined: Sun Sep 11, 2016 2:17 pm
Posts: 568
Have you tried DrawAlphaImage()?
Also you should probably draw on the Screen (use Sprites).
Regarding events i suggest you follow the example (OpenWindowedScreen) in the helpfile.


Top
 Profile  
Reply with quote  
 Post subject: Re: Transparency not working
PostPosted: Thu Oct 10, 2019 12:09 pm 
Offline
Enthusiast
Enthusiast

Joined: Thu Dec 29, 2011 5:03 pm
Posts: 500
When loading an image and assigning it to a variable, you need to use #PB_Any:
Code:
pf = LoadImage(#PB_Any, ”plane.png”)

Drawing on the window won’t show anything if there is a screen on the window. You need to change WindowOutput(0) to ScreenOutput. I would also recommend using Sprites with a Screen.


Top
 Profile  
Reply with quote  
 Post subject: Re: Transparency not working
PostPosted: Thu Oct 10, 2019 12:20 pm 
Offline
User
User

Joined: Sat Apr 13, 2019 12:17 pm
Posts: 43
Thanks for the input guys got it sorted and all is working nicely now using sprites instead of images .


Top
 Profile  
Reply with quote  
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 4 posts ] 

All times are UTC + 1 hour


Who is online

Users browsing this forum: No registered users and 5 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum

Search for:
Jump to:  

 


Powered by phpBB © 2008 phpBB Group
subSilver+ theme by Canver Software, sponsor Sanal Modifiye