【问题标题】:Using the Ruby Shoes GUI toolkit, how would I go about being able to edit my GUI in different areas of code使用 Ruby Shoes GUI 工具包,我将如何在不同的代码区域编辑我的 GUI
【发布时间】:2013-05-13 02:12:57
【问题描述】:

我正在使用 Shoes 编写赛马/投注游戏,我想知道如何在不同的代码区域更改 GUI。当我运行它时,我在一个应用程序上获得马,然后在另一个应用程序上获得比赛线,但我希望它们都在同一个应用程序上。我需要将实际的 Shoes 应用程序本身设置为变量吗?

class Horse 
  def initialize()
    #puts "YOYOYOYO"
    #@number=i
    Shoes.app{
      @icon= image 'horsey.jpg'
      @icon.left = 100
      @icon.top = 50
    }
  end

  def neigh()
    #puts "Neighhhh"
  end

  def raceTime()
    time=rand(100)%20
    return time+10
  end
end

class HorseIcon
  def initialize(h)
    @horse= h
    @imageloc='horsey.jpg'
  end
end

class Game
  def initialize(h1, h2)
    contestants=[h1, h2]
    Shoes.app{
      @icon= image 'raceline.jpg'
      @icon.left = 100
      @icon.top = 70
    }
  end

  def race()
  end
end

game= Game.new(1,2) 
seabiscuit= Horse.new()

【问题讨论】:

    标签: ruby shoes


    【解决方案1】:

    您正在使用两个单独的 Shoes.app 类。我认为这是你的问题。

    从您的代码来看,您似乎有其他语言的背景,例如 Python。 我建议您克隆 Shoes git 并查看“Shoes/samples”目录并使用它。 或者看看this.

    它将帮助您了解代码的外观。

    PS : 它也会给你一些关于 Ruby 风格的指导。使用多行时,您通常不使用 {} 进行块。你会使用:

        Shoes.app do
          # code goes here
        end
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-10-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多