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

beavoid
beavoid used Ask the Experts™
on
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
Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
David FavorFractional CTO
Distinguished Expert 2018

Commented:
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.
Developer & EE Moderator
Fellow 2018
Most Valuable Expert 2013
Commented:
Touching and dragging on a screen is the same as using a mouse is the same as using an external graphic tablet is the same as a touchpad on your laptop.  https://www.kirupa.com/html5/drag.htm

It would really be best to take a few days and start a javascript course.  Don't try and fast forward, start with the basics and go from there https://www.codecademy.com/learn/learn-javascript
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
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.
Ensure you’re charging the right price for your IT

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!

beavoidSelf Employed

Author

Commented:
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
beavoidSelf Employed

Author

Commented:
Thanks,
Scott FellDeveloper & EE Moderator
Fellow 2018
Most Valuable Expert 2013

Commented:
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.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial