开发者

Select underlying objects

Greetings!

I've made a progra开发者_如何学Gom that lets you draw shapes. All shapes are contained in a vector. What I need help with is; when several shapes are stacked on top of each other, I want to cycle through them, top to bottom, if the user clicks repeatedly. I'm thinking something along the lines of:

  1. Store every object under the mouse location where the user clicked in some sort of container
  2. Keep track of which object was first in queue, and should be last (?) after the next click
  3. Repeat step two until the user clicks somewhere that results in a different queue

This is more of a general programming question, rather than just C++, but any help would be greatly appreciated, and if that answer also provides a pretty solution in C++, all the better!


A popular approach to this is to assign each item a z-order. Items with higher z-order hide items with lower z-order if they overlap. In your case, you would just have to find all items below the cursor and rotate their z-orders when the user clicks.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜