[iOS] After 3 times of touch-recycle-create, the game freezes.

sanjordi

  • Posts: 8
In my program, I create the following logic:
Step1: click on item A to recycle itself and create item B on somewhere else
Step2: click on item B to recycle itself and create item C at the same coordinate
Step3: click on item C to recycle itself and re-create item B at the same coordinate

When I test my program, it passes the building process. But, when I play it, the game freezes after I click on item C.

Does anyone have any ideas?

P.S. I put iOS as the prefix since I'm using 'touch' as the user input although I'm currently testing it in flash.

« Last Edit: February 06, 2012, 10:09:42 pm by sanjordi »

rob1221

  • *
  • Posts: 9473
Nope...can you post the relevant behaviors?

sanjordi

  • Posts: 8
Thanks, rob1221.

Below is the code. And, the screenshot of the behavior is also attached. For each step, I use exactly the same logic as what's shown on the screenshot as well as the below code, except the actors are different. Just don't know why it doesn't work at the last step.


   public dynamic class Design_1_1_Select extends ActorScript
   {      
            override public function init():void
      {}
      override public function update():void
      {
      
          if (actor.isMousePressed())
          {
              recycleActor(actor);
              createActor(getActorType(23), 565, 168, FRONT);
          }
      }
      override public function handleCollision(event:Collision):void
      {
      }
      override public function draw(g:Graphics, x:Number, y:Number):void
      {
      }

      public function Design_1_1_Select(actor:Actor, scene:GameState)
      {
         super(actor, scene);
         nameMap["Actor"] = "actor";

      }
      
      override public function forwardMessage(msg:String):void
      {
         
      }
   }

sanjordi

  • Posts: 8
Just to let everyone know - the function I'm trying to implement is check/uncheck function. In other words, I want to click on something to pick it up and save to my inventory. Then, when I click on the item in my inventory, the item should be checked. Then, when I click it again, it should be unchecked.

I figured the 3 steps listed in my post to implement this feature. If it's true there is a bug in StencylWorks blocking me doing that, is there a workaround?

Thanks for your time.

rob1221

  • *
  • Posts: 9473
In that screenshot you recycle self but create a non-recycled actor.  Is that new actor also being recycled?  If so, you should be using the block listed near the recycle block that creates a recycled actor.

sanjordi

  • Posts: 8
You are my hero! Problem solved! Thank you so so so much, rob1221!

You are correct. When I use the 'create recycled....' block, it works.

But, here comes another issue - as you know, I'm trying to do check/uncheck. That means the checked actor and the non-checked actor are located at the same coordinate. I find that when I click there, the program does both check and uncheck the two actions, which means...it does nothing.

I guess it should be solved by using different layers. So, I set one of them to be Middle and the other to be Front when creating them. But, it doesn't seem working for me. Where else should I be looking into?

Thank you again.

rob1221

  • *
  • Posts: 9473
Can the check and uncheck be made into two animations of the same actor?

sanjordi

  • Posts: 8
I created two animations for the actor. Then, I used the below logic in my behavior. Please refer to the screenshot. But, the compiled program doesn't switch the animation to 'animation 1'. I don't know whether the animation hasn't been switched, or the switched animation is hidden behind something?

rob1221

  • *
  • Posts: 9473
Try using an animation attribute instead.  I know in flash you can type in the name, but iStencyl might not allow that.