2014-04-21 2 views
1

고교 졸업 프로젝트에 대한 마감일이 다가오고 있으므로 조언을 해주시면 큰 도움이됩니다. 내 프로젝트는 영화를 코딩하는 것입니다. 아이디어는 처리를 사용하여 토큰과 같은 문자를 이동하고 코드를 사용하여 비와 화재 같은 것들을 애니메이션으로 만듭니다. 현재 이미지를 이동하거나 회전하는 것이 매우 어렵다는 것을 알고 있습니다. 이것은 내 프로젝트의 큰 장애물이다. 내가 가지고있는 현재 코드는 도살과 복잡하지만 여기에 있습니다. 여 주인공, 방사형의 이미지 : https://www.dropbox.com/s/x3gvendnaeftapj/radialoutlinel.png처리 중에 이미지를 회전하고 이동해야합니까?

/* 
Radialrolling 
*/ 
PImage img; // Declare variable "a" of type PImage 
float ballX = 10; 
float ballY = 200; 
float h = 300; 
//create a variable for speed 
float speedY = 2; // spped set to 0 in order to test rotating. Necessary for rolling motion 
float speedX = 0.; 
void setup() { 
    size(800,800); 
    smooth(); 

    noStroke(); 
background(0, 0, 0);// Load the image into the program 
    // change the mode we draw circles so they are 
    // aligned in the top left 
    ellipseMode(CORNER); 
    img = loadImage("radialoutlinel.png"); 



} 

void RadialRoll(){ 

    rotate(0);//if this is anything but 0 ball will appear of screen 
     image(img, ballX, ballY, h, h); //create a continuos rotation using the new fun 

//nctions in the draw things 
} 

void draw() { 

    //clear the background and set the fill colour 
    background(0); 
    fill(255); 





    //draw the circle in it's current position 
// ellipse(ballX, ballY, h,h); 

    //add a little gravity to the speed 
    speedY = speedY + 0; 
    speedX = speedX + .02; 
     ballX = ballX + speedX; 


RadialRoll(); 




    if (ballX > width - h) { 
    // set the position to be on the floor 
    ballX = width - h; 
    // and make the y speed 90% of what it was, 
    // but in the opposite direction 
    speedX = speedX * -1; 

    //switch the direction 
    //speedY = speedY; 
    } 

    if (ballX > width - h) { 
    // set the position to be on the floor 
    ballX = width - h; 
    // and make the y speed 90% of what it was, 
    // but in the opposite direction 
    speedX = speedX * -1; 

    //switch the direction 
    //speedY = speedY; 
    } 
    else if (ballX <= 0) { 
    // if the ball hits the top, 
    // make it bounce off 
    speedX = -speedX; 
    } 
    if (ballY > height - h) { 
    // set the position to be on the floor 
    ballY = height - h; 
    // and make the y speed 90% of what it was, 
    // but in the opposite direction 
    speedY = speedY * -1; 

    //switch the direction 
    //speedY = speedY; 
    } 
    else if (ballY <= 0) { 
    // if the ball hits the top, 
    // make it bounce off 
    speedY = -speedY; 
    } 

} 

어떻게 화면에 이미지를 이동하고 약간의 번거 로움로 회전 할 수 있습니까? 대단히 감사합니다. -TheIronHobo

+0

rotate() 함수가 실제로 무엇을하는지 정확히 이해해야합니다. 첫 번째 중단은 Processing API 여야합니다. http://www.processing.org/reference/rotate_.html –

답변

1

먼저 당신이 당신이 카운터가 정수 값이 증가 될 수있는이

rotate(counter*TWO_PI/360); 

처럼 유창 회전 사용 무언가를 원하는 그렇게 할 때 인수로 (TWO_PI 0의 값) 라디안을 rotate() 기능을보고 모든 draw() 루프. 그러나 이것을 코드 이미지에 추가하면 코드 이미지가 점 [0,0] (왼쪽 위 모서리)을 중심으로 회전하며 회전 1/4의 이미지가 표시되지 않습니다. 더 잘 이해하기 위해 당신은 다음 기본 회전을 시작할 수있는이 TUTORIAL을 읽어야 할 사람 : 다음

PImage img; 
int counter = 1; 

void setup() { 
    size(800, 800); 
    smooth(); 
    background(0, 0, 0); 
    img = loadImage("radialoutlinel.png"); 
    imageMode(CENTER); //you can change mode to CORNER to see the difference. 
} 

void draw() { 
    background(0); 
    fill(255); 

    counter++; 

    translate(width/2, height/2); 
    rotate(counter*TWO_PI/360); 
    image(img, 0, 0, 300, 300); 
} 

을 당신은 또한 원하는 그냥 translate() 첫 번째 매개 변수를 조정합니다 오른쪽 왼쪽에서 이미지를 이동하는 경우.

관련 문제