Roku Developer Program

Developers and content creators—a complete solution for growing an audience directly.
cancel
Showing results for 
Search instead for 
Did you mean: 
squirreltown
Level 8

creepycrawler?

Wow i thinks i found an actual bug...errr Feature! yea thats it.
OK.
screen.Drawscaledobject( 620, 230, 2, 2, varr.but_off ) 'good

So the scale params are supposed to be floats, natch but the above works.
Until you add the ( i swear i saw it somewhere - recently documented alpha parameter) then it errors with type mismatch
screen.Drawscaledobject( 620, 230, 2, 2, varr.but_off, &hFFFFFF99 ) 'no good

but when you do it correctly:
screen.Drawscaledobject( 620, 230, 2.0,2.0, varr.but_off, &hFFFFFF99) 'good

Now it flys!
Kinetics Screensavers
0 Kudos
11 Replies
Romans_I_XVI
Level 7

Re: creepycrawler?

Thanks for this tip. But wait... this "alpha parameter" , are you saying I can colorize my bitmaps?

edit: or do you just mean I can adjust the transparency (alpha)?
0 Kudos
squirreltown
Level 8

Re: creepycrawler?

"Romans_I_XVI" wrote:
Thanks for this tip. But wait... this "alpha parameter" , are you saying I can colorize my bitmaps?

edit: or do you just mean I can adjust the transparency (alpha)?


Both. The whiter your bitmap is the more it will "absorb" the color
So if your bit map is white - screen.drawobject( x, y, bitmap, &hFF00007d) will produce a red bitmap at roughly 50% transparency.
You can thank EnTerr for this tip.
Kinetics Screensavers
0 Kudos
Romans_I_XVI
Level 7

Re: creepycrawler?

This is awesome! I just wish I could get this into a sprite though! I could still do it in a hackish way I suppose, could have a fully transparent sprite for collision handling and then draw this over it. Would I take a performance hit doing that? Or is there a better way of doing it? (I thought it wasn't possible before now so still happy)
0 Kudos
Roku Employee
Roku Employee

Re: creepycrawler?

"squirreltown" wrote:
Wow i thinks i found an actual bug...errr Feature! yea thats it.
OK.
screen.Drawscaledobject( 620, 230, 2, 2, varr.but_off ) 'good

So the scale params are supposed to be floats, natch but the above works.
Until you add the ( i swear i saw it somewhere - recently documented alpha parameter) then it errors with type mismatch
screen.Drawscaledobject( 620, 230, 2, 2, varr.but_off, &hFFFFFF99 ) 'no good

but when you do it correctly:
screen.Drawscaledobject( 620, 230, 2.0,2.0, varr.but_off, &hFFFFFF99) 'good

Now it flys!


Thanks for the bug report. I confirmed the issue.
0 Kudos
Romans_I_XVI
Level 7

Re: creepycrawler?

Ok so I am using this to give the appearance of an object fading out in opacity. I thought that the hex constant &h was just a representative of a decimal intiger, as in &hFFFFFFFF = 4294967295 (http://sdkdocs.roku.com/display/sdkdoc/ ... +Reference Section 3.3). Maybe I was completely wrong. Either way 4294967295 gives me a tinted red bitmap where &hFFFFFFFF gives me what I expected.

I might just not be understanding how hex is being used here, but instead I implimented this function for the time being which is working great, it just seems a bit excessive, figured there might be a more efficient way if anyone here is more knowledgable. Thanks.


Function reduce_transparency_hex(hex)
if hex = &hFFFFFFFF
hex = &hFFFFFFEF
return hex
else if hex = &hFFFFFFEF
hex = &hFFFFFFDF
return hex
else if hex = &hFFFFFFDF
hex = &hFFFFFFCF
return hex
else if hex = &hFFFFFFCF
hex = &hFFFFFFBF
return hex
else if hex = &hFFFFFFBF
hex = &hFFFFFFAF
return hex
else if hex = &hFFFFFFAF
hex = &hFFFFFF9F
return hex
else if hex = &hFFFFFF9F
hex = &hFFFFFF8F
return hex
else if hex = &hFFFFFF8F
hex = &hFFFFFF7F
return hex
else if hex = &hFFFFFF7F
hex = &hFFFFFF6F
return hex
else if hex = &hFFFFFF6F
hex = &hFFFFFF5F
return hex
else if hex = &hFFFFFF5F
hex = &hFFFFFF4F
return hex
else if hex = &hFFFFFF4F
hex = &hFFFFFF3F
return hex
else if hex = &hFFFFFF3F
hex = &hFFFFFF2F
return hex
else if hex = &hFFFFFF2F
hex = &hFFFFFF1F
return hex
else if hex = &hFFFFFF1F
hex = &hFFFFFF0F
return hex
else
hex = &hFFFFFF00
return hex
end if
End Function
0 Kudos
squirreltown
Level 8

Re: creepycrawler?

Here are two bitmaps cross fading.
I know you are using the compositor so you might need some adapting.
for i = 0 to  255
hexcolor = &hFFFFFF00+i
hexcolor2 = &hFFFFFFFF-i
screen.clear(whatev)
screen.drawobject( 0,0, bitmap, hexcolor) 'fading in
screen.drawobject( 0,0, bitmap2, hexcolor2) ' fading out
screen.swapbuffers()
end for
Kinetics Screensavers
0 Kudos
Romans_I_XVI
Level 7

Re: creepycrawler?

Lol, so easy... Thanks! Didn't think it would be as simple as subtracting decimal from the hex Smiley Very Happy
0 Kudos
Romans_I_XVI
Level 7

Re: creepycrawler?

Worked perfect! Still loling over this. Replaced a call to a 50 line function to ...

color = color - 16


Smiley Tongue
0 Kudos
Komag
Level 9

Re: creepycrawler?

I always love when big messy code gets replaced by something elegant and simple Smiley Happy
0 Kudos