Ambiera ForumDiscussions, Help and Support. |
|
|
|||||
|
Hi, how would I change the height of a scene node every second using code please? What I've done so far: Every few seconds (1000ms)>change variable "SandHeight" = "SandHeight" +1 Every few seconds (1000ms)>execute javaScript: var h = ccbGetSceneNodeFromName("RisingSand"); ccbSetSceneNodePositionWithoutCollision(h, 185.941574, SandHeight, -214.547958); Obviously it doesn't work. I do have a workaround for it but I'd like to learn a proper coding method instead. Thanks. |
||||
|
What do you mean by changing height, do you mean change the position? I think you wanted to change the scale of the object. There is an action "Scale Animated" that can do the job scale the object on "Y-axis " every few seconds. It might give the effect as if the sand/water is raising up. Or you can always use change position of an object and use move by a vector on the positive of Y-axis. If you intended to change the position of the object. |
||||
|
Ooo so you want to change the position with coding only. In the above code that you have written there is one slight mistake and that is you are using variable "sandheight" as a string and then adding 1 to it. Just remove the quotation around the variables and it should work fine. You don't even need to define a variable sandheight you can directly increment the position on the Y-axis , and instead of using values for x,and z axis. You can get the current position and use that. So your new code can be like this.
This should work fine, if it doesnt then there might be some typos as am on my mobile device and i make a lot of typos while texting from mobile. |
||||
|
Thank you just_in_case - yes, I meant position, not height. I'll take a look at your code and try it. Really appreciate the help. |
|