display points complicated

So I have no other option besides posting here and asking for a help guys. Here is what am up to:


I have actor 1 which is the main actor and I have display points actor.
What I've done is that when I click on my main actor 1, I get random numbers between 1-10.
My goal here is to have a sum of every click on the display points actor.
I've done everything right but something is missing, maybe you can help me.

So I've added the attribute in the scene, named it points.
I've added self attribute on main actor 1 named it number.
Also added formula so that on click I get random number between 1-10. This works fine.

On display points actor I added display text: game.points
On my main actor 1, I added a rule: actor receives event on touch when pressed
-> added change attribute game.points to game.points+self.number

But here is the problem. On the first click display points actor doesn't show the first number which appeared on the main actor 1. Only after I click second time on main actor 1, only after that display points actor start to show numbers but these numbers are previous numbers from the last click. So basically everything is working well, except that my display point actor is missing one number on its sum.

So my question is how I make that my display points actor show all numbers sum pressed exactly from the very start ?
Please help. Thanks.

If you have questions or if I explained my problem not understandably enough please ask.

Comments

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    You described it fine but if you can post screenshots of your rules or a link to download your project file, I'm sure we can help you fix it.

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    Here's a quick demo of what I think you described (click on the square actor):

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

  • l2gstarl2gstar Member Posts: 19
    edited June 2013
    Here you go:


    main actor 1 window http://postimg.org/image/xyfhj01m5/

    display points window http://postimg.org/image/gwfhh7f5r/


    action when nothing is pressed http://postimg.org/image/r3ufnlhq9/

    action when actor 1 is pressed (notice display points yellow actor doesn't display number 6) http://postimg.org/image/rs3a6jgg1/

    action when actor 1 is pressed second time (notice previous number 6 is now displayed but only on 2nd click which is not what I want ) http://postimg.org/image/u0dgydalt/

    action when actor 1 is pressed 3rd time (notice there is now number 8 on screen the sum of latest number 2 and 1st 6, but now the 3rd number 1 is not calculated) http://postimg.org/image/vn6o93zlt/

    so basically this whole thing is adding late value and not current value, I really need help to make this work correctly so that right from the 1st click value is being added on the display points yellow object and on 2nd click I get the sum of 1st and 2nd and so on.

  • l2gstarl2gstar Member Posts: 19
    Here's a quick demo of what I think you described (click on the square actor):
    oh I see now, coding was different, this will help me a lot thanks!

  • tatiangtatiang Member, Sous Chef, PRO, Senior Sous-Chef Posts: 11,949
    @l2gstar the problem was that you had two When Touch is Pressed rules. GameSalad evaluates rules in parallel so both rules would be true at the same time. That's why is wouldn't choose the value and then add it to the total.

    It's kind of like if you told a child:
    "If the traffic light is green, check both ways for cars."
    "If the traffic light is green, cross the street"

    What you'd really want to say is:
    "If the traffic light is green... check both ways for cars and then cross the street."

    New to GameSalad? (FAQs)   |   Tutorials   |   Templates   |   Greenleaf Games   |   Educator & Certified GameSalad User

Sign In or Register to comment.