Roku Developer Program

Join our online forum to talk to Roku developers and fellow channel creators. Ask questions, share tips with the community, and find helpful resources.
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
phoang
Visitor

dfNewBitmapSet: no <Background> tag in BitmapSet

Hi,

I'm new to BrightScript and Roku development. I'm going through the Roku SDK and I'm on the 4.12.2 v30/bslDefender.brs section. There's an example there and when I added it to the Roku Sample app and run, I get the following message in the debug console:

dfNewBitmapSet: no <Background> tag in BitmapSet

I'm developing on Roku model 4200x with software version 5.3 build 4016. I've included the bslDefender library. I've made sure the .xml file is deployed and that the image exists. I even simplified the xml to

<DefenderBitmapSet>
<ExtraInfo cellsize="40"/>

<Bitmap name="Background" filespec="pkg:/images/background_hd.png" />

</DefenderBitmapSet>


bitmapset = dfNewBitmapSet(ReadAsciiFile("pkg:/images/spriteMap.xml"))


I've looked in other areas of the document for troubleshooting, but to no avail. I can't continue because the bitmapset is still null. What am I doing wrong, what am I missing, or what gives???

Thanks
0 Kudos
5 REPLIES 5
GPF
Visitor

Re: dfNewBitmapSet: no <Background> tag in BitmapSet

<Background name="Background" filespec="pkg:/images/background_hd.png" />


should be Background and not bitmap as the xml start tag.

I see that warning all the time since I am not using a background in my code and don't have it in my xml file.

Troy
0 Kudos
phoang
Visitor

Re: dfNewBitmapSet: no <Background> tag in BitmapSet

Thanks for the reply. I'm just a little confused because the "Snake" sample app doesn't have <Background> defined in their .xml and it runs fine.

http://sourceforge.net/projects/rokusdkexamples/files/snake.zip/download

Is the Roku SDK document outdated then? Can someone from Roku confirm?

Edit: I just ran it with <Background> but now I get an error "no <Bitmap> tag". What is going on? I've included the "v30/bslDefender.brs" library.

Thanks
0 Kudos
GPF
Visitor

Re: dfNewBitmapSet: no <Background> tag in BitmapSet

I get the warning everytime also of dfNewBitmapSet: no <Background> tag in BitmapSet in the debug log but it is just a warning I ignore.

here is my bitmapset.xml

<DefenderBitmapSet>

<Bitmap name="gameTiles" filespec="pkg:/data/tilesv.png">
<Region name="0" x="00" y="00" w="1" h="8"/>
...
<Region name="255" x="00" y="2040" w="1" h="8"/>
</Bitmap>

</DefenderBitmapSet>


I load it up with
    bitmapset = dfNewBitmapSet(ReadAsciiFile("pkg:/data/bitmapset.xml"))

sprites = CreateObject("roArray", 256, true)
for i%=0 to 255
reg="gameTiles."+i%.tostr()
sprites[i%]=bitmapset.regions[reg]
end for


in my draw routine I call
m.screen.DrawObject(x%, (yy%-8), sprites[value%])
0 Kudos

Re: dfNewBitmapSet: no <Background> tag in BitmapSet

I tried to run the Collisions example and the Snowflake example (from the developer blog) but I can't get them to work. The example XML differs from the documentation:

http://sdkdocs.roku.com/display/sdkdoc/ ... efenderbrs

(The example has <BitmapSet> the documentation states <DefenderBitmapSet>)

The example code and docs also say to use <Bitmap and not <Background

The error I am getting is

dfNewBitmapSet: Error parsing XML


ANd this is with the example code, unaltered and also updated with the DefenderBitmapSet opening tags. Both versions fail. Why?

I can see the Library "v30/bslDefender.brs", but do I have to do anything special in Eclipse to use this file? I can't see it in the source download.
0 Kudos
RokuJoel
Binge Watcher

Re: dfNewBitmapSet: no <Background> tag in BitmapSet

My opinion is you will get further faster if you don't worry yourself with the dfBitmapSet - its an extra layer of code that is unnecessary, but bears some resemblance to xml seen on other platforms used in a similar fashion.

You can easily create bitmaps, regions and sprites without it and you don't need to parse any XML to do it:


screen=createobject("roScreen",true,1280,720)
screen.setalphaEnable(true)
layer=1
bitmap=createobject("robitmap","pkg:/images/mm_icon_focus_hd.png")
region=createobject("roRegion",bitmap,0,0,bitmap.getwidth(),bitmap.getheight())
Compositor=createobject("rocompositor")
compositor.setDrawTo(screen,&h000000ff)


Used in a working example:

sub main()
screen=createobject("roScreen",true,1280,720)
screen.setalphaEnable(true)
layer=1
bitmap=createobject("robitmap","pkg:/images/mm_icon_focus_hd.png")
region=createobject("roRegion",bitmap,0,0,bitmap.getwidth(),bitmap.getheight())
Compositor=createobject("rocompositor")
compositor.setDrawTo(screen,&h000000ff)

mySprite=compositor.newSprite(100,100,region,layer)
while true
mysprite.MoveOffset(1,2)
if mysprite.getx() > 1280 then
mysprite.moveto(0,mysprite.gety())
end if
if mysprite.gety() > 720 then
mysprite.moveto(mysprite.getx(),0)
end if
compositor.drawall()
screen.swapbuffers()
end while
end sub



For memory management purposes, you should know how to un-create sprites, bitmaps and regions as well:
MySprite.remove()
region=invalid
bitmap=invalid
screen.swapbuffers()


- Joel


- Joel
Need Assistance?
Welcome to the Roku Community! Feel free to search our Community for answers or post your question to get help.

Become a Roku Streaming Expert!

Share your expertise, help fellow streamers, and unlock exclusive rewards as part of the Roku Community. Learn more.