≡
Products
▼
Support
▼
Company
▼
Forum
Ambiera Forum
Discussions, Help and Support.
Create a new account
,
Search
, or Login:
Create reply in
How to do this?
Posted by:
(you are not logged in)
Enter the missing letter in: "Inter?ational"
(you are not logged in)
Text:
[quote][b][/b] wrote: I created a file as an example for you. At the beginning of a scene, a variable called "NumberOfTimesTimerHasBeenUsed" will be set, with a value of zero. Then, a timer will run every 1000 milliseconds, which is equal to 1 second. You should change the number to the time that you want to pass between each of the ten movements. Inside of the timer, I used this JavaScript code: [code]var Cube = ccbGetSceneNodeFromName("cubeMesh1"); var PositionOfCube = ccbGetSceneNodeProperty(Cube, "Position"); var NewZpositionOfCube = PositionOfCube.z + 15; var NumberOfTimesToUseTimer = 10; var NumberOfTimesAlreadyUsed = ccbGetCopperCubeVariable("NumberOfTimesTimerHasBeenUsed"); print(NumberOfTimesAlreadyUsed); if (NumberOfTimesAlreadyUsed < NumberOfTimesToUseTimer) { ccbSetSceneNodeProperty(Cube, "Position", PositionOfCube.x, PositionOfCube.y, NewZpositionOfCube); NumberOfTimesAlreadyUsed++; ccbSetCopperCubeVariable("NumberOfTimesTimerHasBeenUsed", NumberOfTimesAlreadyUsed); } print(NumberOfTimesAlreadyUsed);[/code] You can delete the two lines that say "print". I used those while testing the code, to see the number of times the timer has been used before and after the variable is changed. You should download the file here and test it: [url]https://drive.google.com/file/d/0Bzn2ExutEoIoU0VYZ055RU9DRU0/view?usp=sharing[/url] Open the CCB file with CopperCube, then press the Test button. When you press the spacebar, the cube will move to ten different positions, one by one, and then it will stop moving. I used this line to move it on the Z position: [b]var NewZpositionOfCube = PositionOfCube.z + 15;[/b] You should change the number "15" to the number of pixels that you want it to move every time. If you want to move the character on the X or Y position instead and you need help, please tell me and I will show you which parts of the code need to be changed to do that.[/quote]
Possible Codes
Feature
Code
Link
[url] www.example.com [/url]
Bold
[b]bold text[/b]
Image
[img]http://www.example.com/image.jpg[/img]
Quote
[quote]quoted text[/quote]
Code
[code]source code[/code]
Emoticons
Copyright© Ambiera e.U. all rights reserved.
Privacy Policy | Terms and Conditions | Imprint | Contact