小编Mud*_*kip的帖子

使用Pixi.js的里程表动画

几天前,我开始开发一个用HTML和javascript编写的动画里程表,我打算在我正在开发的RPG游戏中使用它.此外,我一直在使用Pixi.js来帮助我制作动画.以下2张图片是该计划的主要组成部分:

里程表

在此输入图像描述

一排数字:

在此输入图像描述

这是我迄今为止所取得的成就的印刷品:

在此输入图像描述

基本上,前两个按钮立即(没有动画)更新里程表图像上的数字,基于实际HP和PP文本框中包含的实际HP和PP值.如果按下"设置新值",它将计算实际值和新值之间的差值,将其转换为像素,然后在里程表上执行所需的更改.所有更改都通过controller()方法执行.在此方法中,当HP和PP差值均为零时,会有一个while循环中断.

我已设法controller()正确编程方法,因此里程表中的所有数字都按预期更新.但是,我目前在实现动画方面遇到了一些困难.自从我使用以来Pixi.js,我已经在HTML代码中添加了以下方法,以便创建动画的动作:

function update() {
  renderer.render(container);

  window.requestAnimationFrame(update);
}
window.requestAnimationFrame(update); //called after the method definition
Run Code Online (Sandbox Code Playgroud)

容器的定义如下所示(我也在Odometer和HPPP的构造类中使用了PIXI.extras.TilingSprite.call()):

  function init() {
    container = new PIXI.Container();
    renderer = PIXI.autoDetectRenderer(224, 219, {view:document.getElementById("odometer-canvas")});
    odometer = new Odometer();
    container.addChild(odometer);
    hph = new HPPP(96, 85, 0, 0); //HP - Hundred digit (left)
    container.addChild(hph);
    hpt = new HPPP(128, 85, 0, 0);//HP - Ten digit (middle)
    container.addChild(hpt);
    hpu = new HPPP(160, 85, 0, 0); //HP - Unit digit (right)
    container.addChild(hpu); …
Run Code Online (Sandbox Code Playgroud)

html javascript jquery animation pixi.js

10
推荐指数
1
解决办法
592
查看次数

重新实现 CMFCPropertyGridProperty 类 (MFC) 的最佳方法

几天前,我试图实现一种方法,该方法可以检测属性窗口 ( CPropertiesWnd) 中的值何时更新,并在我的 MFC 应用程序中执行一些其他操作。由于我主要使用CMFCPropertyGridProperty实例来处理属性窗口中包含的信息,因此我决定实现该方法BOOL CMFCPropertyGridProperty::OnUpdateValue()(虚拟),只要属性网格中的某些内容发生更改,框架就会自动调用该方法。因此,由于我无法修改该类CMFCPropertyGridProperty(以及其他文件,例如afxpropertygridctrl.h),因此我创建了一个辅助类来执行此操作:

#pragma once


// CMFCPropertyGridPropertyAux

class CMFCPropertyGridPropertyAux : public CMFCPropertyGridProperty
{
public:

    CMFCPropertyGridPropertyAux(const CString& strGroupName, DWORD_PTR dwData=0, BOOL bIsValueList=FALSE);
    CMFCPropertyGridPropertyAux(const CString& strName, const COleVariant& varValue, LPCTSTR lpszDescr = NULL, DWORD_PTR dwData = 0,
        LPCTSTR lpszEditMask = NULL, LPCTSTR lpszEditTemplate = NULL, LPCTSTR lpszValidChars = NULL);
    virtual ~CMFCPropertyGridPropertyAux();
    BOOL OnUpdateValue();
};


// MFCPropertyGridPropertyAux.cpp : implementation file
//

#include "stdafx.h"
#include "MFCProject.h"
#include "MFCPropertyGridPropertyAux.h"


// CMFCPropertyGridPropertyAux

CMFCPropertyGridPropertyAux::CMFCPropertyGridPropertyAux(const …
Run Code Online (Sandbox Code Playgroud)

c++ inheritance mfc

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

将值从float数组传递给double数组时的奇怪行为(C,C++)

我正在开发一个使用NI-DAQ的应用程序,以下是提供商提供的一些方法.

void someMethod(Calibration *cal, float myArray[], float result[]) 
{
    newMethod(&cal->rt,myArray,result,cal->cfg.TempCompEnabled);
}

void newMethod(RTCoefs *coefs, double myArray[],float result[],BOOL tempcomp) 
{
float newMyArray[6];
    unsigned short i;

    for (i=0; i < 6; i++) 
    {
         newMyArray[i]=myArray[i];
    }

}
Run Code Online (Sandbox Code Playgroud)

我基本上调用someMethod(),为myArray []和result []提供一个包含六个元素([6])的数组.正如你在代码中看到的那样,之后调用newMethod(),并将float myArray [6]传递给double myArray []参数(我真的不明白为什么这段代码的开发人员选择使用双数组,因为在newMethod()中声明的唯一数组是float类型.

现在我的问题出现了:在for循环中,一些值没有任何问题,但是当第四个和第五个值传递给newMyArray []时,它会收到两个值的"-1.#INF0000".乍一看,我认为这将是一些垃圾值,但每次执行时都会出现"-1.#INF0000".

我知道C语言有时会很棘手,但我真的不知道为什么会这样......

c c++ arrays nidaqmx floating-point-precision

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