Touch function and moving objects
Moderator: InsideQC Admins
4 posts
• Page 1 of 1
Touch function and moving objects
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!
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!
-

CocoT - Posts: 695
- Joined: Tue Dec 14, 2004 5:39 pm
- Location: Belly-Gum
4 posts
• Page 1 of 1
Who is online
Users browsing this forum: No registered users and 1 guest