ScrollView2D and DrawLine

PenguinHero

Member
Licensed User
Longtime User
Hi All,

I'm using ScrollView2D and all is fine with the imageviews I place on it.
But when I went to use DrawLine (using the canvas that the ScrollView2D is on) I found the lines wouldn't appear until I commented out the background image for the ScrollView2D.

Is there a way to have both? To have the lines drawn on top of the background and imageviews so that they are visible?

I want to be able to scroll the ScrollView2D with its background image moving too, not just have a static image. The way it is now it all scrolls correctly, I just don't see the lines I want while the background is present.
In case its not clear I want the lines to scroll too.

Thanks,
PH
 

PenguinHero

Member
Licensed User
Longtime User
Thanks klaus

Attached is a zip file made using the B4A menu option.
I have cut out pretty much everything from the project that wasn't needed.

The result of the DrawLine is still not visible unless you comment out the line that sets the scrollview background image to the Grass bitmap.

I'm hoping I'm just doing something fundamentally wrong that someone knowledgeable can point out to me. :)


Thanks,
PH
 

Attachments

  • ExampleProj.Zip
    52.2 KB · Views: 262
Upvote 0

Informatix

Expert
Licensed User
Longtime User
Thanks klaus

Attached is a zip file made using the B4A menu option.
I have cut out pretty much everything from the project that wasn't needed.

The result of the DrawLine is still not visible unless you comment out the line that sets the scrollview background image to the Grass bitmap.

I'm hoping I'm just doing something fundamentally wrong that someone knowledgeable can point out to me. :)


Thanks,
PH

- A game with a scrolling map should never be done this way (and similar games are not done this way; they use map tiles loaded when needed). You're using a lot of memory to display only a subset of the map. But that's not the main problem, so let's go on.

- You created the panel with the line behind the ScrollView2D (the panel is created first). How can you hope that it will be displayed above?

- Drawing the frame in the canvas is costly. You should create a frame with an opaque background, then place it in an ImageView (SetBackgroundImage) and create it first, so it's behind everything else. Now resize the scrollview and the drawing panel to fit the frame inner space. Advantages: when you clear your canvas (DrawColor(0)), you do not have to redraw the frame and that removes a big transparent image (you get more CPU time for useful things).

If you want good performance for your drawing stuff, take a look at my new library "AcceleratedSurface". It's better than drawing in a panel.
 
Upvote 0

PenguinHero

Member
Licensed User
Longtime User
Thanks for the feedback Informatix.

I understand some of what you are saying, and will work through the rest.

And I'll have a look at your library that you pointed me to.
 
Upvote 0
Top