Hello Guest

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Messages - amit.r007

Pages: [1]
1
Support / Re: Rotating Sprite on Touch and Drag
« on: June 18, 2014, 12:31:03 pm »
Any thoughts on this ?? :)

2
Support / Rotating Sprite on Touch and Drag
« on: June 17, 2014, 11:22:25 am »
Hi Unikron,

In my 2D game I have a circular sprite which I want to rotate as per touch input. I want to rotate that 2D sprite on z- Axis, say like a 2D Car steering (x and y fixed) according to the touch and drag of a finger/thumb.

Please help me regarding the same.

Thanks,
Amit

3
Support / Re: Movement of Sprite Restricted by ButtonUpEvent
« on: June 11, 2014, 04:19:59 pm »
I took two bool moveLeft and moveRight and handled the code accordingly in update. It worked great, but can you tell me what was the mistake in my previous code. Is it the sequence of events getting called that caused the issue, I want to get it cleared ... :D :D

Thanks,
Amit

4
Support / Movement of Sprite Restricted by ButtonUpEvent
« on: June 11, 2014, 06:10:46 am »
Hi Unikron,

I am making a 2D game in Unity, I have a sprite and two buttons left and right to the sprite in respective direction.

My logic goes this way, on ButtonDown event I move sprite and on ButtonUp I stop moving.  I am able to move the sprite in both directions on buttondown event, but when I release one button and suddenly press second button the movement of sprite stops and I have to again press that button to start moving.

Here is my code,
Code: [Select]
void Start(){
      GameObject.Find ("Btn_Left").GetComponent<tk2dButton> ().ButtonDownEvent += MoveLeft;
      GameObject.Find ("Btn_Left").GetComponent<tk2dButton> ().ButtonUpEvent += StopMoving;
      GameObject.Find ("Btn_Right").GetComponent<tk2dButton> ().ButtonDownEvent += MoveRight;
      GameObject.Find ("Btn_Right").GetComponent<tk2dButton> ().ButtonUpEvent += StopMoving;
}

void Update(){
      Sprite.transform.Translate(IPDir *0.1f,0,0);
}

void MoveLeft (tk2dButton source)
{
Debug.Log("Left is Pressed");
IPDir = -1;
}

void MoveRight (tk2dButton source)
{
IPDir = 1;
}

void StopMoving (tk2dButton source)
{
               IPDir = 0;
}

Everything works great except for that part when I am moving in right and suddenly I release right and press left and viceversa, the sprite stops moving. I had enabled multitouch option in editor, multitouch works great, but when dont know why it is not taking the next ButtonDown event when I am Releasing one button.

Help me regarding this, I searched on forums but could not get closer to my solution.

Regards,
Amit

Pages: [1]