I am trying to get multiple bouncing(flying) balls moving around inside a background area.
The problem i have is that my tutors says i can not use the preferred method of canvas or jquery. as i am new to javascript can anybody help me out with any solutions to this problem please ?
i dont have any code to provide for this.
cheers.
1 Replies - 438 Views - Last Post: 19 December 2012 - 08:00 AM
#1
How to get multiple bouncing balls not using a canvas ?
Posted 19 December 2012 - 07:14 AM
Replies To: How to get multiple bouncing balls not using a canvas ?
#2
Re: How to get multiple bouncing balls not using a canvas ?
Posted 19 December 2012 - 08:00 AM
Well, you could just create <img> elements with ball images, set up a timer to execute a function every 1000/60 milliseconds (~16.667), and inside that function update the positions of those balls using the standard Javascript style properties.
Here are some references to get you started:
document.getElementById()
Gets an element on the page by it's "id" attribute. Use this to grab a reference to your image elements to be used in your Javascript code.
element.style
This is how you manipulate the CSS styles of elements in Javascript code.
About Element Positioning
An explanation of the various ways in which elements can be positioned using CSS. Pay special attention to Absolute and Relative positioning.
window.setInterval
This allows you to execute code repeatedly every X milliseconds.
Here are some references to get you started:
document.getElementById()
Gets an element on the page by it's "id" attribute. Use this to grab a reference to your image elements to be used in your Javascript code.
element.style
This is how you manipulate the CSS styles of elements in Javascript code.
About Element Positioning
An explanation of the various ways in which elements can be positioned using CSS. Pay special attention to Absolute and Relative positioning.
window.setInterval
This allows you to execute code repeatedly every X milliseconds.
Page 1 of 1
|
|

New Topic/Question
Reply


MultiQuote





|