LB Booster
Programming >> Language extensions >> Multiple graphic controls having sprites?
http://lbb.conforums.com/index.cgi?board=extensions&action=display&num=1422958087

Multiple graphic controls having sprites?
Post by datwill on Feb 3rd, 2015, 09:08am

I thought I read somewhere in LBB (or it could just be my imagination) that multiple graphic boxes/windows can have sprites. Is this true with LBB?
Re: Multiple graphic controls having sprites?
Post by Richard Russell on Feb 3rd, 2015, 09:46am

on Feb 3rd, 2015, 09:08am, datwill wrote:
I thought I read somewhere in LBB (or it could just be my imagination) that multiple graphic boxes/windows can have sprites. Is this true with LBB?

I don't think it is. If you attempt to draw sprites in more than one graphicbox/window I expect you will get exactly the same sprites and exactly the same background in both, which is unlikely to be very useful!

Presumably what you are asking for is independent sprites, background etc. for each box/window. That might be possible but it's a lot of work.

Richard.

Re: Multiple graphic controls having sprites?
Post by datwill on Feb 3rd, 2015, 10:09am

Don't worry, if it isn't possible I'm not really asking you to add it (I do mean independent/unique sprites for multiple graphic controls), only if you want to! I'm pretty sure I can evade this problem anyway by making multiple apps work together.
Re: Multiple graphic controls having sprites?
Post by Richard Russell on Feb 3rd, 2015, 9:57pm

on Feb 3rd, 2015, 10:09am, datwill wrote:
Don't worry, if it isn't possible I'm not really asking you to add it.

Try this (it uses sprites from the LB examples folder so you should save the program there):

Code:
    nomainwin

    loadbmp "smiley1", "sprites\smiley1.bmp"
    loadbmp "crab1", "sprites\crab1.bmp"
    loadbmp "bg1", "sprites\bg1.bmp"
    loadbmp "bg2", "sprites\bg2.bmp"
    open "sprite window 1" for graphics_nsb as #g1
    UpperLeftX = 100
    open "sprite window 2" for graphics_nsb as #g2
    #g1 "trapclose [quit]"
    #g1 "addsprite smiley1 smiley1"
    #g1 "spritetravelxy smiley1 200 250 1 [landed]"
    #g2 "trapclose [quit]"
    #g2 "addsprite crab1 crab1"
    #g2 "spritetravelxy crab1 200 250 1 [landed]"
    timer 40, [animate]
    wait

[animate]
    #g1 "background bg1"
    #g1 "spritevisible smiley1 on"
    #g2 "spritevisible crab1 off"
    #g1 "drawsprites"
    #g2 "background bg2"
    #g1 "spritevisible smiley1 off"
    #g2 "spritevisible crab1 on"
    #g2 "drawsprites"
    wait

[quit]
    close #g1
    close #g2
    end

[landed]
    wait 

Richard.
Re: Multiple graphic controls having sprites?
Post by Richard Russell on May 27th, 2016, 09:28am

There's currently a thread at the Just BASIC forum discussing a problem arising from attempting to use sprites in two different windows or graphicboxes, which is not supported by JB or LB.

Perhaps this is a good opportunity to point out that, with care, you can use sprites in multiple windows in LBB; this Wiki article describes how. There's an overhead, because it's not a feature I specifically designed for, but it's not too onerous.

Richard.