A couple problems.

ArchonStudiosArchonStudios Member, PRO Posts: 23
Hi everyone! I have a couple things that I am looking for some help on, maybe someone here can help me out.

Problem 1:
I have multiple actors spawning at random locations on the screen. The object of the game is to tap these actors to remove them as fast as possible. Sometimes, new actors will spawn over old ones. When I tap an actor that sits on top of another one, they both destroy. How do I prevent the tap from going through both actors and only affect the top most actor?

Problem 2:
Looking for some instruction on how to create a slingshot like effect such as in angry birds. I have been able to replicate the "cannon" effect and shoot a ball out at an angle with a velocity dependent on the distance of the touch from the cannon. However, I have been unable to replicate the effect of touching and dragging backwards, and having the ball get thrown like it is getting flung from the slingshot.

Any help would be greatly appreciated. Please do not point me to any templates that I have to pay for, I have already considered purchasing some and when I have the opportunity to, I will. For now, I am interested in maybe getting a walk-through or some sort of push in the right direction. I have tried and tried (especially with the slingshot), and have not yet been able to figure it out.

Comments

  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    For your first problem look at these two videos.





    For your second question. You need to use an expression to convert the number positive I believe the floor function might work as it will keep the number whole.

  • ArchonStudiosArchonStudios Member, PRO Posts: 23
    Thanks, I have checked out those videos before.

    The problem with the first video is that tshirtbooth manually places actors on the screen, unlocks each one, and then changes values within the actors. I will only have a spawner on screen, and then the objects will randomly appear on the screen, so unlocking them to give them different values will not work in this case. The second video is cool and shows a good use of tables, but in this case I do want some overlapping to occur. Any suggestions on how to tap just the object on the top layer and destroy it without going through to any actors underneath?

    For the second, I am not quite sure I follow you. Can you give an example of how that would work? What attributes would I need to keep track of in order to get the angle and velocity correct? The way I thought it should work:
    1. Constrain slingshot rotation to game.launchAngle
    2. Touch and hold slingshot and drag finger back to desired location.
    3. On release -
    a. set game.launchAngle to -(max(0,min(90,vectorToAngle(self.Position.X - mousePosition.X, self.Position.Y - mousePosition.Y)))
    b. set game.launchVelocity to -(vectorToAngle(self.Position.X - mousePosition.X, self.Position.Y - mousePosition.Y))
    c. Spawn Actor
    4. Actor should have change velocity to game.launchVelocity

    Am I close? What am I doing wrong?
  • The_Gamesalad_GuruThe_Gamesalad_Guru Member Posts: 9,922
    edited July 2013
    Why would you need vector to angle for speed? what you want is to define a min and max based on the speed window you need. once you set the direction which you have right all you need is to define the speed. similar to the way the cannon template does it but using your pull distance as the calculation and you can top it off at a number.
  • ArchonStudiosArchonStudios Member, PRO Posts: 23
    Awesome, I will give that a try tonight when I get home. I am not really sure why I had vector to angle for speed. probably because I wasn't looking at any of my work when I was writing it, but rather trying to think off the top of my head. Thanks for your insight.
Sign In or Register to comment.