基本运行周期不起作用

时间:2016-07-06 19:15:37

标签: python pygame

我还是python的新手,并且已经开始使用pygame了。我正在进行一场无尽的亚军比赛,但我的跑步周期遇到了问题。这是我的代码:

protected void onPostExecute(JSONObject json) {

    int success = 0;
    String message = "";

    Log.d("postexxec pa2welcome", "starting");
    if (pDialog != null && pDialog.isShowing())
    {
        pDialog.dismiss();
    }

    else if (json != null)
    {
        String formid = "";
        String date = "";
        JSONArray data = null;
        try {
            data = json.getJSONArray("details");
            JSONObject obj = data.getJSONObject(0);
            formid = obj.getString("formID");
            date = obj.getString("event_date");

            **Log.d("formid", formid); // Not displaying
            Log.d("date..",date); // Not displaying**

        }
        catch (JSONException e) {
            e.printStackTrace();
        }

        try {
            success = json.getInt(TAG_SUCCESS);
            message = json.getString(TAG_MESSAGE);
        }
        catch (JSONException e) {
            e.printStackTrace();
        }
    }
    else
    {
        Toast toast = Toast.makeText(
                        welcome.this,
                        "unsuccessful",
                        Toast.LENGTH_LONG
        );
        ViewGroup group = (ViewGroup) toast.getView();
        TextView messageTextView = (TextView) group.getChildAt(0);
        messageTextView.setTextSize(20);
        messageTextView.setTypeface(Typeface.SERIF);
        toast.show();
    }
}

所以屏幕正在滚动,我的角色出现了,但是他停留在第一个位置(我估计框架)在它运行的部分07-05 21:20:42.524 22779-23117/com.example.somya.client_feedback_application D/request pa2welcome: starting 07-05 21:20:42.528 22779-22779/com.example.somya.client_feedback_application D/preexec: starting 07-05 21:20:42.542 22779-23117/com.example.somya.client_feedback_application D/JSON Parser: result: {"welcome":"successful","details":[{"formID":"19","event_date":"2016-06-03"}],"success":1,"message":"successful"} 07-05 21:20:42.542 22779-23117/com.example.somya.client_feedback_application D/JSON result pa2welcome: {"welcome":"successful","details":[{"formID":"19","event_date":"2016-06-03"}],"success":1,"message":"successful"} 07-05 21:20:42.543 22779-23117/com.example.somya.client_feedback_application D/reqpostasyncwelcome: starting 07-05 21:20:42.561 22779-23117/com.example.somya.client_feedback_application D/JSON Parser: result: {"success":1} 07-05 21:20:42.561 22779-22825/com.example.somya.client_feedback_application W/EGL_emulation: eglSurfaceAttrib not implemented 07-05 21:20:42.566 22779-22825/com.example.somya.client_feedback_application W/OpenGLRenderer: Failed to set EGL_SWAP_BEHAVIOR on surface 0xe19b0560, error=EGL_SUCCESS 07-05 21:20:42.575 22779-22779/com.example.somya.client_feedback_application D/postexxec pa2welcome: starting 我尝试让它在设置姿势之前打印一些东西,它做了什么,但它没有设置姿势。我试着让它打印出姿势,它表明姿势并没有改变。所以,是的,我已经找到了我的问题,但我不能为我的生活找到解决方案。

1 个答案:

答案 0 :(得分:1)

而不是尝试通过引用传递 - 这就是你正在做的事情,尝试这样的事情:

def set_pose(pose):
    if pose >= 4:
        return 1
    else:
        return pose + 1

然后当您尝试在其他位置更新pose变量时:

pose = set_pose(pose)

您是否同意您可以随意调用函数的参数?例如,set_pose看起来像这样,并且完全同样的事情:

def set_pose(foo):
    if foo >= 4:
        return 1
    else:
        return foo + 1

换句话说,仅仅因为它在函数内部被称为pose并不意味着它将引用外部函数。