LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

How can I focus the screen on a particular element of a large 2D array?

I am making a LabView game based on a 2D array of boolean LED's. The player is able to scroll around this array to select any LED from an almost limitless number of LED's depending on the diffulculty level selected. As such the game array spills off the side of the screen. Is there a way of centring the front panel display on to a particular element within a 2D array?

 

I am thinking that I may have to generate a "Display" array which would be a subset of the main array with fixed dimensions less than that of my display. I would populate my Display array with the corresponding elements from the "Too large to Display Array" that would maintain the element of interest at it's centre. Does this sound like the best approach?

0 Kudos
Message 1 of 3
(2,811 Views)

Give this a try: https://decibel.ni.com/content/docs/DOC-8546

 

I haven't run it myself.  But, it appears to update the indicator to the values you select.  If that's the case, you can implement logic to center it as you please.

0 Kudos
Message 2 of 3
(2,793 Views)

There are two issues:

 

  1. Detecting which element has been clicked
  2. scrolling the array to recenter at the click position.

For problem 1, I would use an array indicator and mouse down events. You can easily get the coordinates of the moused element from the coordinates given by the event data node. A simple example is my 4x4 tic tac toe game (see image). Please have a look at the code and let me know if anything is not clear. If the array is scrolled, you need to also account for the index of the top left corner element.

For problem 2 you can just set the array index as already suggested based on the shift. You might even animated it and scroll through all intermediate position for a smoother look.

 

How big is the "world"? If this is a gigantic boolean array it might be better to just display the relevant subset instead of sending everything to the indicator. I would also use simple booleans from the "classic" palette (e.g. Flat square button") for the array elements. it is much cheaper to redraw a simple square compared to a shaded LED.

 

0 Kudos
Message 3 of 3
(2,767 Views)