Sprite mit Transparent? [Erledigt]

Übersicht BlitzBasic Blitz3D

Neue Antwort erstellen

Ironstorm

Erstklassiger Contest-Veranstalter

Betreff: Sprite mit Transparent? [Erledigt]

BeitragSo, März 05, 2006 0:49
Antworten mit Zitat
Benutzer-Profile anzeigen
Hi @ all!

Hab mich mal mit Pixel Sharp befasst. Hab eigentlich alles gecheckt. Nur mein prob. ist nun, wie bekomme ich es hin das ich die Sprites (2D fake Grafiken) wie echte Grafiken mit z.b. Schwaarz transparent mache? Also so das z.b. ein loch in der Textur ist. Also ich bin echt am ende und hab alles versucht.

Hier ist mal der Code den ich von blitzbasic.com geholt habe:

Code: [AUSKLAPPEN]

; pixies.bb
; by skidracer

; pixies are pixel perfect sprite overlays

; LoadPixie(camera,imagefile$)

; returns a sprite parented to a camera
; with following features
;  1:1 pixel-texel scale for zero filtered sharp overlays
;  position pixies in screen coordinates

; 20.8.2003 untested with odd sized sprites
; 21.8.2003 modified to handle odd textures

displaywidth=1024
displayheight=768

Graphics3D displaywidth,displayheight 

cam=CreateCamera()
CameraRange cam,.1,1000
pixie=Loadpixie(cam,"simon1.jpg")


While Not KeyHit(1)

fpscount=fpscount+1
If fpstime + 999 < MilliSecs() Then
fpstime=MilliSecs()
fps=fpscount
fpscount=0
EndIf
PositionEntity pixie,MouseX(),MouseY(),0
TurnEntity pixie,1,0,0

RenderWorld
UpdateWorld
TurnEntity cam,1,2,0;test texel drift
Text 0,0, fps
Flip
Wend
End



Function LoadPixie(camera,file$)
; load squared texture
texture=LoadTexture(file)
width=TextureWidth(texture)
height=TextureHeight(texture)
image=LoadImage(file)
iwidth=ImageWidth(image)
iheight=ImageHeight(image)
If iwidth<>width Or iheight<>height
buffer=TextureBuffer(texture)
ibuffer=ImageBuffer(image)
For y=0 To height-1
For x=0 To width-1
WritePixel x,y,ReadPixel(x,y,ibuffer),buffer
Next
Next
ScaleTexture texture,Float(width)/iwidth,Float(height)/iheight ; will blitzmax need float()?
width=iwidth
height=iheight
EndIf
FreeImage image
; change these for viewports
viewwidth=GraphicsWidth()
viewheight=GraphicsHeight()
; find existing pixiespace parented to camera
magic=0
n=CountChildren(camera)
For i=1 To n
If EntityName(GetChild(camera,i))="pixiespace"
magic=GetChild(GetChild(camera,i),1)
EndIf
Next
If magic=0
magic=CreatePivot(camera)
NameEntity(magic,"pixiespace")
aspect#=Float(viewheight)/viewwidth
PositionEntity magic,-1,aspect,1
scale#=2.0/viewwidth
ScaleEntity magic,scale,-scale,-scale
magic=CreatePivot(magic)
PositionEntity magic,-.5,-.5,0
EndIf
; create sprite from texture as child of magic overlay
sprite=CreateSprite()
EntityParent sprite,magic;cludge for blitz bug in createsprite(parent)
brush=CreateBrush()
BrushFX brush,1
BrushTexture brush,texture
PaintEntity sprite,brush
FreeBrush brush
SpriteViewMode sprite,2
scale#=1.0/viewwidth
ScaleSprite sprite,width*scale,height*scale

Return sprite
End Function


Und hier das Bild dazu:
user posted image

Genau die Schwarze Fläche versuche ich Transparent zu machen.

Ich hoffe ihr könnt mir helfen.

THX im vorraus

Blitzmaker
  • Zuletzt bearbeitet von Ironstorm am So, März 05, 2006 13:28, insgesamt einmal bearbeitet
 

Dreamora

BeitragSo, März 05, 2006 3:24
Antworten mit Zitat
Benutzer-Profile anzeigen
Indem du bei LoadTexture noch die Flag für MaskTexture angibst.
Siehe in der Hilfe oder www.blitzbase.de
Ihr findet die aktuellen Projekte unter Gayasoft und könnt mich unter @gayasoft auf Twitter erreichen.

Ironstorm

Erstklassiger Contest-Veranstalter

BeitragSo, März 05, 2006 4:35
Antworten mit Zitat
Benutzer-Profile anzeigen
*hust* Upps, habs vergessen.

^^ Sorry Embarassed

THX

Neue Antwort erstellen


Übersicht BlitzBasic Blitz3D

Gehe zu:

Powered by phpBB © 2001 - 2006, phpBB Group