如何在红宝石/鞋子中移动图像?

时间:2019-01-24 20:23:18

标签: ruby-on-rails image animation

我目前正在编写“吃豆人”游戏。现在我想让我的幽灵从左向右移动。我只是想不通... 我试着移动一个规则的圆圈,它很有趣!但是一旦我想移动我的图像就不起作用了,有什么办法可以解决这个问题吗?还是不能以这种方式对图像进行动画处理?

Shoes.app width: 900, height:600 do

  flow width: 0.9, height: 0.9 do
    stack width: 0.8, height: 1.0 do
    end
    background black

#field
  fill blue
  rect(270, 0, 60, 60)
  rect(0, 290, 60, 60)
  rect(540, 290, 60,60)
  rect(270,420 , 60, 60)
  rect(290, 100, 20, 50)
  rect(180, 100, 240, 20)
  rect(290, 240, 20, 50)
  rect(180, 270, 240, 20)
  rect(290, 340, 20, 30)
  rect(130, 180, 50, 30)
  rect(420, 180, 50, 30)
  rect(220, 340, 160, 10)

  stroke white

  line(50,50,100,50)
  line(50, 50, 50, 100)
  line(500, 50, 550, 50)
  line(550, 50, 550, 100)
  line(150, 50, 210, 50)
  line(150, 50, 150, 70)
  line(390,50 ,450, 50)
  line(450, 50, 450, 70)
  line(100, 100, 100, 160)
  line(100, 160, 80, 160)
  line(0, 200, 50, 200)
  line(100, 200, 80, 200)
  line(100, 200, 100, 260)
  line(500, 150, 500, 250)
  line(550, 200, 600, 200)
  line(500, 150, 520, 150)
  line(500, 250, 520, 250)
  line(240, 180, 240, 220)
  line(360, 180, 360, 220)
  line(50, 380, 50, 430)
  line(50, 430, 100, 430)
  line(110, 320, 110, 380)
  line(80, 380, 140, 380)
  line(190, 400, 190, 440)
  line(180, 400, 190, 400)
  line(420, 400, 420, 440)
  line(420, 400, 430, 400)
  line(480, 430, 540, 430)
  line(540, 380, 540, 430)
  line(460, 320, 460, 370)
  line(420, 370, 490, 370)

  #images
  @image1 = image"pacman.png", height: 25, width: 25, left:290, top: 180
  @image2 = image"bomb.png", height: 30, width: 30, left:200, top:300
    @image3 = image"bomb.png", height: 30, width: 30
    @image4 = image"bomb.png", height: 30, width: 30
    @image5 = image"bomb.png", height: 30, width: 30
  @image6 = image"pizza-slice.png", height: 30, width: 30, left:300, 
top:300

   #bombs
    @timer1= timer(5) do
      @image2.move(60,70)
      @image3.move(150,300)
      @image4.move(400,230)
      @image5.move(500,380)
    end

     @image2= timer(15) do
      @image2.move(60,170)
      @image3.move(80,300)
      @image4.move(230,230)
      @image5.move(500,300)
    end

    @image3= timer(25) do
      @image2.move(470,50)
      @image3.move(510,190)
      @image4.move(20,400)
      @image5.move(100,50)
    end

   #moving ghost
   speed = 1
   x = 150
   y = 10
   dir   = 1    
ghost = image"ghost.png", height: 30, width:30, left:170, top:60

   @moving_ghost = animate (60) do
      y =  y + speed*dir
    ghost.move(x, y)
      if image.left >= height() or image.left <= 0 then
         dir = -dir 
      end
end


#showing score
   stack width: 0.2, height: 0.15 do
   background burlywood
     @image8 = image"chronometer.png", height: 30, width: 30, left: 30, 
top: 5
     @image9 = image"score.png", height: 30, width: 30, left: 100, top: 0
   end
end    

0 个答案:

没有答案