umesh1988
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015
05:33 AM
Remove layer from top or middle using RoScreen
It has become apparent that I will need to use roScreen in my program instead of roImageCanvas
in order to speed up my program, regarding layer in roImageCanvas, use the setLayer, clearLayer and swapLayer
but when i am using roScreen how i will remove layer that is in top or middle without remove the first layer.
I am giving code in that i want to remove middle layer that i.e "pkg:/images/2.jpg
Any suggestions?
in order to speed up my program, regarding layer in roImageCanvas, use the setLayer, clearLayer and swapLayer
but when i am using roScreen how i will remove layer that is in top or middle without remove the first layer.
I am giving code in that i want to remove middle layer that i.e "pkg:/images/2.jpg
sub main()
screen=createobject("roscreen",true)
'screen.setalphaenable(false)
screen.setalphaenable(true)
image1=createobject("robitmap","pkg:/images/1.jpg")
image2=createobject("robitmap","pkg:/images/2.jpg")
image3=createobject("robitmap","pkg:/images/3.jpg")
'lets set up some positions for these images:
obj1={posx:100,posy:100}
obj2={posx:200,posy:200}
obj3={posx:300,posy:300}
timer=createobject("rotimespan")
timer.mark()
while true
screen.setalphaenable(true)
screen.clear(&h000000ff)
screen.drawobject(obj1.posx,obj1.posy,image1)
screen.setalphaenable(false)
screen.drawobject(obj2.posx,obj2.posy,image2)
screen.setalphaenable(false)
screen.drawobject(obj3.posx,obj3.posy,image3)
screen.swapbuffers()
end while
end sub
Any suggestions?
5 REPLIES 5

RokuMarkn
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015
07:12 AM
Re: Remove layer from top or middle using RoScreen
You would just add an "if" statement to decide whether to draw the bitmap.
--Mark
screen.clear(&h000000ff)
screen.drawobject(obj1.posx,obj1.posy,image1)
if should_draw_layer_2 then
screen.setalphaenable(false)
screen.drawobject(obj2.posx,obj2.posy,image2)
end if
screen.setalphaenable(false)
screen.drawobject(obj3.posx,obj3.posy,image3)
--Mark
umesh1988
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015
09:49 PM
Re: Remove layer from top or middle using RoScreen
Thanks, But I am already drawing three images using Bitmap in three layer In the given code, my requirement is that how to remove or hide the layer that is in top or middle without hide the first Image.

TheEndless
Channel Surfer
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015
09:57 PM
Re: Remove layer from top or middle using RoScreen
"umesh1988" wrote:
Thanks, But I am already drawing three images using Bitmap in three layer In the given code, my requirement is that how to remove or hide the layer that is in top or middle without hide the first Image.
RokuJoel gave you the code to do that. In your While loop, you need to add logic that only draws the layers you want displayed.
My Channels: http://roku.permanence.com - Twitter: @TheEndlessDev
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
Instant Watch Browser (NetflixIWB), Aquarium Screensaver (AQUARIUM), Clever Clocks Screensaver (CLEVERCLOCKS), iTunes Podcasts (ITPC), My Channels (MYCHANNELS)
umesh1988
Visitor
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-21-2015
10:38 PM
Re: Remove layer from top or middle using RoScreen
We are using roScreen to display a static map and on top of static map we are animating a group of 10 images for overlay.
Following is the code for animating the overlay image. Where m.mylocal[] contains path of 10 local images
The problem is we are not able to remove the animating overlay images from the stack. so after some time the black screen is appearing on the screen.
Please advise how we can clear the stack of overlay without hiding static map.
Following is the code for animating the overlay image. Where m.mylocal[] contains path of 10 local images
Function Animate()
while true
m.screen.SetAlphaEnable(true)
for j=0 to 9 step 1
sleep(500)
bitmap=CreateObject("roBitmap", m.mylocal[j])
m.screen.DrawObject(0,0, bitmap)
m.screen.Finish()
end for
end while
end function
The problem is we are not able to remove the animating overlay images from the stack. so after some time the black screen is appearing on the screen.
Please advise how we can clear the stack of overlay without hiding static map.

RokuJoel
Binge Watcher
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
01-22-2015
02:39 PM
Re: Remove layer from top or middle using RoScreen
First of all, you are doing something very inefficient which is creating the bitmaps at the same time you are drawing them. If they need to be animated, create an animated sprite from an array of regions, or create an array of bitmaps and draw those in your loop:
As to hiding images, you would want to have a conditional value in an array parallel to the bitmap array as to whether something should display or not. Here's an example:
This way you can do other things and your UI won't have to pause for 500ms for animation updates.
- Joel
As to hiding images, you would want to have a conditional value in an array parallel to the bitmap array as to whether something should display or not. Here's an example:
Function SetupAnimation()
m.screen.SetAlphaEnable(true)
m.animationArray=createobject("roArray",9,true)
m.drawarray=createobject("roArray",9,true)
for j=0 to 9 step 1
m.animationArray[j]=CreateObject("roBitmap", m.mylocal[j])
m.drawarray[j]=true
end for
end function
Function Animate()
animation_timer=createobject("rotimespan")
animation_timer.mark()
m.screen.SetAlphaEnable(true)
j=0
while true
if animation_timer.totalmilliseconds() >= 500 then
if m.drawarray[j] then
m.screen.DrawObject(0,0, bitmap)
end if
animation_timer.mark()
end if
j=j+1
if j > 9 then j=0
end while
end function
This way you can do other things and your UI won't have to pause for 500ms for animation updates.
- Joel