Forum

Touch function and moving objects

Discuss anything not covered by any of the other categories.

Moderator: InsideQC Admins

Touch function and moving objects

Postby CocoT » Sun May 07, 2006 10:37 pm

Hi there again :)

Ok, I have a little question for you.
I've created an new object for a mod I'm working on and used its think() function to make it moves from one side to the other, using something like this:

if (self.alternatemoves == 0)
{
self.origin_x = self.origin_x + 2;
self.moveswitch = self.moveswitch + 1;
if (self.moveswitch == 50)
{
self.moveswitch = 0;
self.alternatemoves = 1;
}
if (self.alternatemoves == 1)
{
self.origin_x = self.origin_x - 2;
self.moveswitch = self.moveswitch + 1;
if (self.moveswitch == 50)
{
self.moveswitch = 0;
self.alternatemoves = 0;
}
}


Now, the problem is that, even though my object is moving around, it seems that the touch() function will only be called when the player is located at the original starting point of that object, so not necessarily when he/she touches that object as it appears on the screen, a little bit on the left or on the right of its starting point. Do you have an idea why it is so?

Thanks a lot in advance! :-)
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum

Postby FrikaC » Sun May 07, 2006 10:48 pm

Use setorigin instead.
FrikaC
Site Admin
 
Posts: 1026
Joined: Fri Oct 08, 2004 11:19 pm

Postby CocoT » Mon May 08, 2006 12:13 pm

Yay, it works! :)

Thanks so much, FrikaC, I really appreciate it :-)
User avatar
CocoT
 
Posts: 695
Joined: Tue Dec 14, 2004 5:39 pm
Location: Belly-Gum

Postby RenegadeC » Mon May 08, 2006 1:23 pm

Oh CocoT, you crazy coconut you!
User avatar
RenegadeC
 
Posts: 391
Joined: Fri Oct 15, 2004 10:19 pm
Location: The freezing hell; Canada


Return to General Discussion

Who is online

Users browsing this forum: No registered users and 1 guest