How do I count total weight of sprites on game?

0 favourites
  • 2 posts
From the Asset Store
An educational game for counting pictures. An easy to use template for developers to build larger games
  • I have one sprite wit 3 animation frames: 1kg, 2kg, 5kg

    What events should looks like when i want to calculate total weight?

    if frame animation 0 is displayed add 1kg

    if frame is 1 add to total 2kg

    if frame displays 2 animation frame add 5kg to total weight

    also when i click mouse button on one sprite weight total weight should calculate again

    when i spawn new weight also should sum all weights on game and display on text?

  • Try Construct 3

    Develop games in your browser. Powerful, performant & highly capable.

    Try Now Construct 3 users don't see these ads
  • You can use "For Each Sprite" loop:

    For Each Sprite
    .. Sprite animation frame=0 : Add 1 to totalWeight
    .. Sprite animation frame=1 : Add 2 to totalWeight
    .. Sprite animation frame=2 : Add 5 to totalWeight
    

    If you need to recalculate the weight often you can make a function:

    Function RecalcWeight
    .. Set totalWeight to 0
    
    .. For Each Sprite
    .... Sprite animation frame=0 : Add 1 to totalWeight
    .... Sprite animation frame=1 : Add 2 to totalWeight
    .... Sprite animation frame=2 : Add 5 to totalWeight
    
Jump to:
Active Users
There are 1 visitors browsing this topic (0 users and 1 guests)