Sorry your browser is not supported!

You are using an outdated browser that does not support modern web technologies, in order to use this site please update to a new browser.

Browsers supported include Chrome, FireFox, Safari, Opera, Internet Explorer 10+ or Microsoft Edge.

Dark GDK / Move problem

Author
Message
Yero008
13
Years of Service
User Offline
Joined: 5th Dec 2010
Location: Romania
Posted: 2nd Aug 2011 19:16 Edited at: 2nd Aug 2011 19:18
I have an object that I'm trying to move up and down. The problem is that the object starts going up but won't come down. This is the code:

The object that I'm trying to move is naveta. Can anyone help me?
Edit:The Y of the object seems to change fast from 399 to 400 when at top.
Forward thanks.
Mr Bigglesworth
16
Years of Service
User Offline
Joined: 4th Mar 2008
Location:
Posted: 2nd Aug 2011 19:56
An "IF ELSE" statment requries braces {}. It should look like this:
Hassan
15
Years of Service
User Offline
Joined: 4th May 2009
Location: <script> alert(1); </script>
Posted: 2nd Aug 2011 20:21 Edited at: 2nd Aug 2011 20:26
not always, it's valid if there is only 1 line after it without braces

@Yero008
try either have sw static:


or make it global, i.e. define it outside functions in global scope, for example:


because, your code seems to be inside a loop, and sw is initialized to true everytime the loop is executed, meaning it's always true unless object Y is 400, when that happens, the code below it will move down, and Y will be 399, then the loop goes again, sw is true, and we're at 399, thus, will stay true and go up, and so on..
one more possible solution, is to declare the bool sw = true right before the loop, in the scope right above it,this is messy, making it global is also messy, static looks better and cleaner, though, you should be careful when using it in OOP, doesn't seem to be your case

also:

that could sometimes cause errors, not in your case, but if you want to move object at speeds different than 1, this is safer:


Yero008
13
Years of Service
User Offline
Joined: 5th Dec 2010
Location: Romania
Posted: 3rd Aug 2011 00:03 Edited at: 3rd Aug 2011 00:14
I succeded with the movement, thank you Hassan. But I have another problem with the sparky plug-in. If I jump on the moving object, but my player doesn't go up with the platform it just stays in the same position in the air, where the objects initial positon is.
This is how I load the object:

Is there anything I can do?
Many Thanks!
L.E: I solved it using SC_UpdateObject(naveta);

Login to post a reply

Server time is: 2024-05-23 10:53:51
Your offset time is: 2024-05-23 10:53:51