Framework Code for Animation

Use this code as a guideline for setting up the program to create your animation.


World.frameRate = 30;

// Set up variables for sprites

var kid2Standing = createSprite(370, 340);
kid2Standing.setAnimation("kid2_standing");
kid2Standing.scale = 0.18;

var kidLWalking = createSprite(25, 350);
kidLWalking.setAnimation("kid1_walking");
kidLWalking.scale = 0.2;
kidLWalking.visible = false;


// Set up variables for counters and triggers


var together = false;
var happy = false;
var count = 0;
var jumpCount = 0;

// Draw a scene where two girls meet after school to talk about 

// what stresses them pit

function draw() {


// draw background and initial position of girls
background("SkyBlue");
fill("green");
rect(0, 350, 400, 50);


// girls walk toward each other while school shrinks
kid1Standing.visible = false;
kid2Standing.visible = false;
kidLWalking.visible = true;
kidRWalking.visible = true;


kidLWalking.x = kidLWalking.x + 1;
kidRWalking.x = kidRWalking.x - 1;
kidLWalking.y = kidLWalking.y - 0.2;
kidRWalking.y = kidRWalking.y - 0.2;
kidLWalking.scale = kidLWalking.scale + 0.003;
kidRWalking.scale = kidRWalking.scale + 0.002;


if (school.scale > 0.18) {
school.scale = school.scale - 0.004;
school.x = school.x + 2.6;
school.y = school.y + 0.3;
}

// when girls get together they talk it out


kidLWalking.x = kidLWalking.x + 1;
kidRWalking.x = kidRWalking.x - 1;
kidLWalking.y = kidLWalking.y - 0.2;
kidRWalking.y = kidRWalking.y - 0.2;
kidLWalking.scale = kidLWalking.scale + 0.003;
kidRWalking.scale = kidRWalking.scale + 0.002;
tadaSound();


// The very last step in this function is always to draw the sprites


drawSprites();

}



//Function to make the sound


function tadaSound(){

playSound("sound://category_achievements/vibrant_virtcal_achievment.mp3", false);
}

No comments:

Post a Comment

Contact Form

Name

Email *

Message *