query regarding this logic

slider17slider17 Member Posts: 13
edited May 2014 in Working with GS (PC)

hi

i am having an issue with which logic to proceed with in relation to the action i want to take for the following scenario.

three actors in the scene. one actor is a button that goes backward. another actor is also a button that goes forward. the third actor is an image.

now when i press the forward button what i want is for the current image actor to be destroyed and then the next image actor to be spawned in its place, so on and so forth until all the image actors have been displayed. something like an image carousel.

ok now for the logic part.

  • create a new game attribute called "image1" and set it to 1
  • create a rule within the forward btn that states when it is touched set the "image1" attribute to 0
  • within the first image actor set a rule that checks if the "image1" attribute is set to 0, if so destroy the actor.
  • finally within the same forward btn rule as above, a definition that spawns the next image actor onto the stage in place of the actor that just got destroyed.

the above works, but i got a feeling it may start to get complicated when i start introducing all the image actors to come.

should i use a control actor instead?? how could i implement this??

of course the other option would be to create a new scene for every image actor, and the forward btn just moves to the next scene. but i feel that may bloat the final game package.

thanks

Comments

  • TosanuTosanu Member, PRO Posts: 388

    Is there a reason you are using separate actors as opposed to just using the Change Attribute: Self.Image rule? This prevents all the destroying.

    But if you want to do it this way, your best bet is to instead make an attribute called image number. And make the button instead do this function. Imagenumber =(imagenumber+1). if you want the function to go back to the first image after the last one, add(%number of images) at the end. Then have an actor that checks this function. When imagenumber = 2, spawn secondactor.

    All image actors should have a rule that says if imagenumber =! personal image number, destroy this actor.

    In the other option, that i suggest, you instead put the rule on the image actor, with (When image number = 1, change self.image to image one, and so on)

  • slider17slider17 Member Posts: 13

    hi Tosanu

    thanks for the reply. was not aware of the Self.Image rule. im brand new to GS.

    see i also want the user to touch the image and then the image animates and plays a sound. this i have already programmed. i just need to figure out the forward btn programming. movign onto the next image.
    can i still do this with the self.image rule??

  • colandercolander Member Posts: 1,610

    I have attached a project with forward and back buttons which shows how to change images in an actor using a table. Is this what you are after?

    It was done in Mac Creator but you will be able to open it in Windows Creator. I can't remember how that was done if you don't know just google it.

  • slider17slider17 Member Posts: 13

    Hi colander

    appreciate the effort you went to to put together that example. much appreciated.
    its definitely more advanced than what i am putting together.

    i have managed to get the logic to work out the way i want it to. i will though use your example for future reference.

Sign In or Register to comment.