Home | Documentation | Atomic Chat | Github

How to move a sprite to new x,y co-ordinates?


I am just now trying out Atomic Game Engine and auditing it’s scripting and ease of development. I am having trouble understanding the documentation especially how to form commands using the API reference for JavaScript. As a result I cannot figure out how to move a sprite from one co-ordinate to another.
So far I have tried:

and all manner of variants.

I guess what I am hoping for is some guidance on how to relate the API documentation in order to correctly form a command using the idea of moving a sprite instantly from it’s starting position to another co-ordinate.

Thank you.


When I started, I had a lot of trouble with JavaScript as well, and I eventually just switched to C# (once I got going, I was able to understand what was going on in my code much better) , but I think you should write this:

self.node.position = [x, y, z];

And if you do make the switch to C#, the line would be:

Node.Position = new Vector3(x, y, z);

Hope it works out for you!
And if you have trouble later Atomic Examples is a great place for figuring out what you need to do:


Thank you Clockwork, I did try to use “position” along the way but got the same strange functionality I got with the expressions I listed which was my sprite disappeared from the screen. I see now my error was using () instead of []. Would you happen to know if it is written somewhere when Atomic expects [] rather than ()? I am surprised to find that the command’s coordinates seem to be treated like a simple array rather than something like just coordinates. Also, thank you for the advice. If this engine is more understandable in C# I might go ahead and switch.


I think that it uses the square brackets because the variable position is an array, rather than a function like you said, but I could be wrong, and glad I could help! And in my opinion, C# is the way to go in Atomic, but that could just be my style.

In the case that it is an array, your set position function could be

self.node.setPosition([x, y, z]);


Turns out you are absolutely correct. Your expression did make “setPosition” work as I intended. Thank you very much.


No Problem, Glad I could help!

And also, just saw this a second ago

So an answer to your question about whether or not vector threes are arrays