Drawer overlay each other possible?

MM2forever

Active Member
Licensed User
Longtime User
Hi,
I created some code corresponding to the
bouncing ball example.
The problem is that I wanna add a second image
on top of the first one, but Im cracking my mind with
what Im doing wrong - or maybe its not possible.
These are the parts of my code that are might
important:

transparentColor = ImgList.Pixel(0,1,1)
SetTransparentColor(transparentColor)
eraseBrush.new1(transparentColor)
Form.forelayer=true

rectSrc.new1(0,0,ImgList.width(0),ImgList.height(0))
rectDest.New1(50,120,ImgList.width(0),ImgList.height(0))

armSrc.new1(0,0,ImgList.width(11),ImgList.height(11))
armDest.New1(50,120,ImgList.width(11),ImgList.height(11))
drawer.new1("Form", True)
drawer.DrawImage1(ImgList.Item(0),rectSrc.Value,rectDest.Value,true)
drawer.Refresh2(rectDest.Value)

drawer.DrawImage1(ImgList.Item(11),armSrc.Value,armDest.Value,true)

Here are the lines for refreshing on movement (not
involving the overlay texture yet):

Sub hkey_HardKeyPressed
Select hkey.keypressed
Case hkey.keyright
drawer.FillRectangle(eraseBrush.Value,rectDest.Value)
drawer.Refresh2(rectDest.Value)
rectDest.X = rectDest.X + 3
drawer.DrawImage1(ImgList.Item(r),rectSrc.Value,rectDest.Value,true)

If r=3 Then
r=-1
End If
r=r+1

Case hkey.keyleft
drawer.FillRectangle(eraseBrush.Value,rectDest.Value)
drawer.Refresh2(rectDest.Value)
rectDest.X = rectDest.X - 3
drawer.DrawImage1(ImgList.Item(l),rectSrc.Value,rectDest.Value,true)

If l=7 Then
l=3
End If
l=l+1

End Select
End Sub
 

hung

Active Member
Licensed User
Longtime User
Hi,
The problem is that I wanna add a second image
on top of the first one, but Im cracking my mind with
what Im doing wrong - or maybe its not possible.

I also have same problem but seems can not solve in current version.
http://www.b4x.com/forum/showthread.php?t=638

I found that in b4ppc's repaint loop, the transparency of forelayer will take the background layer to replace the transparent color

Alternatively you can draw everything on background layer and in your redraw loop, use drawer (imagelib) to draw the portion of the background first, then draw the first ball with transparency, finally draw the second ball with transparency overlapping the first ball.
 
Top