Link to home
Start Free TrialLog in
Avatar of James Hancock
James HancockFlag for United States of America

asked on

How do I move game objects with a finger in Javascript?

Hi.
I think my <script> learning curve would be most boosted right now, if I could see a .js /htm that allows a player to move a circle /square/dodecahedron / pterodactyl around the screen with a finger.

Also, I see some coders do their scripting inside html and <script> tags and others in .js
Is it inconsequential? or simply a preference.

Thanks
Avatar of David Favor
David Favor
Flag of United States of America image

You asked, "How do I move game objects with a finger in Javascript?"

Easiest to use a library for this. https://blog.bitsrc.io/11-javascript-animation-libraries-for-2018-9d7ac93a2c59 provides one list + there are many additional Javascript Animation Libraries you can explore.

Experiment with various libraries till you find one which provides feature set you require for app you're developing.
ASKER CERTIFIED SOLUTION
Avatar of Scott Fell
Scott Fell
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
I see some coders do their scripting inside html and <script> tags and others in .js
Is it inconsequential? or simply a preference.
It is the same thing.  For long scripts  or scripts that will be used on multiple pages, you will typically see an external file such as
<script src="/path_to/scripts/helloworld.js"></script>

Open in new window

The hellowworld.js will look like
alert("hello world");

Open in new window

When the script is a one off for that page, you will see scripts inside the script tags like
<script>
alert("hello world");
</script>

Open in new window

The external js files do get cached in the browser and this is reason to load it externally along with writing code in just one place.
Avatar of James Hancock

ASKER

Thanks,
As a CS major, does that Academy course cover things that I'd definitely not know, and need to be aware of as a C++/Java pro
It is a big commitment. 12 hours,
but I'd need to know CSS and HTML associated with  JavaScript sites.

For the games I'm going to make, I'm sure I can't leave anything unlearnt. Will it cover touch-select-move?
Will that course cover it all? I am confident that the pages I've found from all my other EE questions on Javascript could get me going immediately. I've got enough examples working to see all the mechanics in place. My major intensions are bullet-proof networking and seamless cross-platform gameplay.
Do you think it's not worth taking the risk of misunderstanding core issues?
Is that course just a class about variable scope, OOP, for loops, if's?
Thanks
Thanks,
The  codecademy gets you a good basic understanding of the language while getting you up and running quickly compared to reading

When taking your college level courses, did you first start out learning the basics of java and progress to more complex or did you start out programming a payroll system off the bat?   You have to (should) start at the beginning.  You already understand logic so you will be ahead of the game so to speak.  However, if you try to take shortcuts, in the end you will have spent more time going back and forth, fixing and getting it right compared to starting from the start.  I see this happening here all the time.  

Separate the back end and front end. Java being the back end and html/css and javascript being the front end unless of course you are using node, then JS can be the front and back end.  The progression I suggest is learning basic HTML, then CSS then Javascript.  If you have to take a 10 to 20 hour time out to just get the basics understood, it is very small compared to the amount of time you will be frustrated and asking basic questions and waiting for answers.  It will be time saved in the long run if that makes sense.  

Is that course just a class about variable scope, OOP, for loops, if's?
yes, as it pertains to javascript. OOP is not in the basic course. It also covers how JS can interact with the DOM which you will need. But this is why you should start with HTML/CSS first.  

There is also a lot of good info on mozilla https://developer.mozilla.org/en-US/docs/Learn/JavaScript/Objects/Object-oriented_JS. That link also has info for html and css. What I like about the codecademy is you learn interactively vs reading.  The best way to learn is get the basics and then apply to your live project.