View previous topic :: View next topic |
Author |
Message |
CocoT

Joined: 14 Dec 2004 Posts: 599 Location: Belly-Gum
|
Posted: Sun May 07, 2006 10:37 pm Post subject: 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!  |
|
Back to top |
|
 |
FrikaC Site Admin

Joined: 08 Oct 2004 Posts: 947
|
Posted: Sun May 07, 2006 10:48 pm Post subject: |
|
|
Use setorigin instead. _________________
 |
|
Back to top |
|
 |
CocoT

Joined: 14 Dec 2004 Posts: 599 Location: Belly-Gum
|
Posted: Mon May 08, 2006 12:13 pm Post subject: |
|
|
Yay, it works!
Thanks so much, FrikaC, I really appreciate it  |
|
Back to top |
|
 |
RenegadeC

Joined: 15 Oct 2004 Posts: 370 Location: The freezing hell; Canada
|
Posted: Mon May 08, 2006 1:23 pm Post subject: |
|
|
Oh CocoT, you crazy coconut you! |
|
Back to top |
|
 |
|