Help with a 'for loop' kinda thing

froptfropt Member, PRO Posts: 9

Hi guys,

I have a problem that I'm not beeing able to solve, I was wondering if you could help me:
I'm creating a very simple educational game. It's about recycling.

I have 6 actors: Plastic, Metal, Paper, Glass, Batteries and Trash and 8 images for each actor.
Actors must be spawned in this order with 2 second interval, but at each round they should have a new image, until 8th.

I've created an atribute wichActor (Int) and a Spawner that every 2 seconds spawns a diferent actor and adds 1 to wichActor. (working fine)

Now, I can't get the 'changing image at each turn' to work...

So you can have a better ideia, I got this almost working but everything random.
https://youtube.com/watch?v=QqaSQehEmes

Now I was asked to keep a specific order for the actors... And I'm freaking out... I just need a for loop..

Can someone help me please?

Thanks in advance,
fropt

Comments

  • HopscotchHopscotch Member, PRO Posts: 2,782
    edited December 2016

    @fropt

    I am a bit confused as to what you are asking now. :)

    What do you mean by "each turn"? Should the items spawn in a specific order, but start with a new item (next in line) each time the level starts?

    Are you still having an issue with the "change image" behavior?
    You can rename your images to "item_1.png", "item_2.png", etc.
    Then you can use the Change image behavior thus:

    Change image: self.image = "item_"..self.wichActor

  • froptfropt Member, PRO Posts: 9

    Hi,
    sorry took me so long to reply.. It's kinda stupid we don't get notified by email when someone replies to a subject we created or responded.

    I've solved the issue, thank you. I've used atribute changing and tables.

    Explanation : the game's about recycling. I have 6 actors: Plastic, Metal, Paper, Glass, Batteries and Trash..
    Actors are spawned in this order with 2 second interval with a specific order.
    When the last actor (e.g. Trash) is spawned, the cycle begins again.

    The thing I was looking for was, instead of having 48 actors I wanted 8 actors with a diferent image at each spawn. For example:
    Round 1
    Plastic(water_bottle.png) Metal(soda_can.png) Paper(card_box.png) Glass(beer_botle.png)...) etc...
    Round 2
    Plastic(plastic_fork.png) Metal(sardine_can.png) Paper(news_paper.png) etc...

    Anyway, it's a solved issue, thank you all for your time and effort

Sign In or Register to comment.