小编use*_*310的帖子

Unity 2D健康栏

我是编码和Unity的新手

我的健康栏出现在我的屏幕上,但我不确定如何将健康栏的健康脚本链接到我的播放器脚本和播放器的健康脚本.简单地说,我想这样做,当我的球员被击中时,我的健康棒会失去一颗心

我的健康栏脚本

using UnityEngine;
using System.Collections;

public class Health : MonoBehaviour {

    public int startHealth;
    public int healthPerHeart;

    private int maxHealth;
    private int currentHealth;

    public Texture[] heartImages;
    public GUITexture heartGUI;

    private ArrayList hearts = new ArrayList();

    // Spacing:
    public float maxHeartsOnRow;
    private float spacingX;
    private float spacingY;


    void Start () {
        spacingX = heartGUI.pixelInset.width;
        spacingY = -heartGUI.pixelInset.height;

        AddHearts(startHealth/healthPerHeart);
    }

    public void AddHearts(int n) {
        for (int i = 0; i <n; i ++) { 
            Transform newHeart = ((GameObject)Instantiate(heartGUI.gameObject,this.transform.position,Quaternion.identity)).transform; // …
Run Code Online (Sandbox Code Playgroud)

c# unity-game-engine

7
推荐指数
2
解决办法
1万
查看次数

Python中的Fibonacci - 解释这段代码?

我对编码很新,我一直在为Alex Bowers的初学者使用Python.在每一章的最后是一个实验练习,这个特别的一个是关于Fabonacci,章节本身是关于forLoops,whileLoops,Try Except和Finally,以及break和Continues.我对解决方案感到困惑,尤其是处理变量"set"的行,任何人都可以向我解释解决方案,因为他们没有在书中解释它...谢谢

f0 = 0
f1 = 1
set = False              
while True:
    fn = f0 + f1
    f0 = f1
    f1 = fn 
    if (fn > 100):
        set = True
    else:
        set = False
    print(fn)
    if (set == True):
        break 
Run Code Online (Sandbox Code Playgroud)

python

0
推荐指数
1
解决办法
239
查看次数

标签 统计

c# ×1

python ×1

unity-game-engine ×1