LONG SERIES OF HTML5 GAMES: chapter1 part8

Qaybta Xirfada Sayniska iyo iwm

Moderators: Moderators, Junior Moderators

User avatar
afisoone
SomaliNet Super
SomaliNet Super
Posts: 5509
Joined: Wed Jul 22, 2009 9:46 pm
Location: We all want to become president even though Amisom controls Mogadishu

LONG SERIES OF HTML5 GAMES: chapter1 part8

Post by afisoone »

Now the hardest part went. Everything else is easy..

Now let's answer what is screen wrapping?

Screen wrapping is when an image disappears one side and reemerges on the opposite side. That is what is called screen wrapping. ok

How do you do that in this arrow image... We need to add some codes functionka updateStageka();

open your Object.js file and let add some codes on updateStageka. Since our arrow image is running left to right we are going to add this
simple code..
function updateStageka()
{
window.requestAnimationFrame(updateStageka, canvaska);

arrow.x++;


if(arrow.x>canvaska.width)
{
arrow.x=0-arrow.width;
}



hadbaSawir();


}
Beautiful: Now what we said is simple. If the canvaska haduu dhaafo imageka. Then So gali the arrow image from the other side.

anagoo ku dhahnay
arrow.x=0-arrow.width;
Soo now let's watch what we did..here is the Demo

So now the image reappears again when it finishes the other end... Beautiful
---------------------------------------------------------------------------------------------------------------------

Here is the another question. Why the arrow Image is crossing the left of the canvaska.

How do we stop it?

We will next lesson inshallah!

<<Previous Lesson
  • Similar Topics
    Replies
    Views
    Last post

Return to “Careers - Engineering, Science & Computers”