Win a copy of Head First Agile this week in the Agile forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Displaying multiple colors in my triangle shape?  RSS feed

 
Luong Vuong
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi i have made a game where users click on the screen and a red triangle appears correspinding to where they clicked. How do make the game act so that when i/user clicks on the screen the user would see for example the colours red, blue, green, yellow in that order in each triangle. Would i need to use the Cardlayout functionality ? if not, how?
The code for it to be red is as follows:
 
Svend Rost
Ranch Hand
Posts: 904
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I dont know the context of this problem, so this might not be the best
solution.. it is an easy one though.

Have an array of Colors, and when you loop through the number of triangles
you wish to draw you simply call the .setColor(myColourArray[i]) method,
where i is the loop variable in your for-statement.

You'd also have to change the coordinates, else the triangles would be
painted on top of each other.

How does this solution sound in your context / problem?

/Svend Rost
 
Luong Vuong
Greenhorn
Posts: 8
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
That does in a way go into context. At this present moment in time i can click on the screen and my shape appears(triangle), that also inturn starts a timer. I belive i may not have provided you with enough coding, if so sorry about that.




I've included a timer for this so that when the user clicks anywhere on the screen, the timer goes. colours used in this order; red, green, blue, then back to begining.

Ideally this is what i would like to happen when a user clicks on the screen:

a triangle appears > timer starts > the triangle is red> then green > then blue > then red etc ...
This should happen for every triangle that i click on the screen.
Do you think it is necessary to add a timer for this situation? If so how would i modify it to do this?

If not, based on u'r last comment and with my extra coding, again how would i modify it?

Hope this is clearer. Again, sorry for not adding more code.
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!