Touch Control

Talk about making games.

Touch Control

Postby Behdadsoft » Thu Feb 20, 2014 2:48 pm

Hi.

I want Control the Player in xVelocity by click on the screen and move it (-x,+x).
I made it according to Draw Function. but there is a Problem that when I click on the screen, the Player move to click point like adventure games. Now I don't wan't this. I wan't when Click on the screen and move mouse, the Player move only at X coordinate and when release Mouse Button stop the Player at last Position.

first,I made a canvas actor on the screen and added this codes.
Create Actor >> Script Editor:
Code: Select all
draw = 0;


Mouse Button Down (Left) >> Script Editor:
Code: Select all
screen_to_actor (&xmouse, 0);
actor_to_screen (&xmouse, 0);
draw = 1;


Mouse Button Up (Left) >> Script Editor:
Code: Select all
draw = 0;


Draw Actor >> Script Editor:
Code: Select all
if (draw == 1)
{
    MoveTo("Player", 0, 0, 3, "Mouse Position", "");
}

"Mouse Position": Relative to point (xmouse,ymouse). I think one Problem is Related "Mouse Position" because have xmouse and ymouse, While I need only xmouse.

Please Guide Me to Solve this Problem.

Thanks A LOT
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: Touch Control

Postby skydereign » Mon Feb 24, 2014 9:06 am

You need to stop the move in your mouse up event. To do so you can do MoveTo("Player", 0, 0, 1, "Player", "").
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Touch Control

Postby Behdadsoft » Mon Feb 24, 2014 5:49 pm

Thanks skydereign. :D
+1

I want my actor only move at x coordinate, while it move at all direction. can you say me how can fix it?
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: Touch Control

Postby skydereign » Tue Feb 25, 2014 12:34 pm

Behdadsoft wrote:I want my actor only move at x coordinate, while it move at all direction. can you say me how can fix it?

I'm not entirely sure I understand what you mean. If you only want it to move on the x axis you can just do this.
Code: Select all
MoveTo("Player", view.x+xmouse, Player.y, 3, "Game Center", "");

What this is doing is moving the player to the point to the mouse, without it moving on the y axis. This is done by making the y destination the actor's current y.
User avatar
skydereign
 
Posts: 3510
Joined: Mon Jul 28, 2008 8:29 am
Score: 589 Give a positive score

Re: Touch Control

Postby Behdadsoft » Tue Feb 25, 2014 5:22 pm

If you only want it to move on the x axis you can just do this.


Yes, I Only want the Player Move on the x axis. but this code give an error:

wrong number of arguments for MoveTo


What this is doing is moving the player to the point to the mouse, without it moving on the y axis. This is done by making the y destination the actor's current y.


This is a screenshot from My game that I made it for android, but I want control movement with touch:
Attachments
SpaceInvaders.jpg
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score

Re: Touch Control

Postby lcl » Tue Feb 25, 2014 5:28 pm

The reason for the error was that there was one comma missing from the function call.
Here's the fixed version:
Code: Select all
MoveTo("Player", view.x+xmouse, Player.y, 3, "Game Center", "");

So the comma missing was after the number 3, which is the speed for the actor's movement.
User avatar
lcl
 
Posts: 2339
Joined: Thu Mar 25, 2010 5:55 pm
Location: Finland
Score: 276 Give a positive score

Re: Touch Control

Postby Behdadsoft » Wed Feb 26, 2014 6:04 pm

ohhh, Thanks lcl. :D

+1
There is no possible way, if we found will make a way.

http://behdadsoft.com/
*******************************************************************
My Game : Star Wars 1.0

http://behdadgame.com/index.php?topic=3.0
User avatar
Behdadsoft
 
Posts: 207
Joined: Wed Dec 16, 2009 9:19 pm
Score: 2 Give a positive score


Return to Game Development

Who is online

Users browsing this forum: No registered users and 1 guest