Quantcast
Channel: Library Questions - Processing 2.x and 3.x Forum
Viewing all articles
Browse latest Browse all 2896

Using Sprite Library

$
0
0

Hi so I have figured out on how to use the sprite library but now I don't know how to scroll through the animations frequently basing what I want the character to do any ideas on how to do

import sprites.*;
import sprites.maths.*;
import sprites.utils.*;
Sprite player;
int i=0;
float pos_x, pos_y;
void setup()
{
  size(600, 600, P2D);
  player=new Sprite(this, "https://opengameart.org/sites/default/files/daxbotsheet.png", 4, 4, 2);
  player.setFrameSequence(0, 40, 20);
}

void draw()
{

  background(255);
  translate(width/2, height/2);
  translate(pos_x, pos_y);
  player.draw();
  if (key==CODED)
  {
    if (keyCode==LEFT)
    {
      pos_x-=3;
    } else if (keyCode==RIGHT)
    {
      pos_x+=3;
    } else if (keyCode==UP)
    {
      pos_y-=3;
    } else if (keyCode==DOWN)
    {
      pos_y+=3;
    }
  }
}

Viewing all articles
Browse latest Browse all 2896

Trending Articles