In box2d you can turn on the outline of the shape to debug you do this with
m_debugDraw->SetFlags(flags);
And it is called debug draw
Well I have a set of distance joint that I am trying to debug and was wondering if there was a function just like dubug draw but for distance joints. I am currently working on a blob made up of many nodes all connected by spring like distance joints and to debug it would help if I could see where the joints are... Any help is much appreciated thankyou
m_debugDraw->SetFlags(b2Draw::e_jointBit);
Should show the joints, I use a combo in my project to show everything like this:
uint32 flags = 0;
flags += b2Draw::e_shapeBit;
flags += b2Draw::e_jointBit;
flags += b2Draw::e_aabbBit;
flags += b2Draw::e_pairBit;
flags += b2Draw::e_centerOfMassBit;
debugDraw->SetFlags(flags);
found that info at http://www.cocos2d-iphone.org/forum/topic/21311
Related
When you build an application in Qt Creator you can see the Issues you get while building in the Issues pane, at the bottom of the screen. So far I've seen the yellow triangle (warning), the full red circle (seems to be a compilation error) and an empty red circle.
While I'm pretty confident about the first two, I can't figure out what the empty red circle means, since the compilation doesn't stop but it's not a warning either. The circle appears next to some C++ lines of code.
By clicking on the funnel icon on top of the Issues pane, I could filter out the output and see all the categories. It seems like the empty red circle indicates a Clang Code Model issue.
When i start an Animation (using the code below), allof the sprites.png's are misscolored (red) except for the starting picture, so it looks like it's blinking red.
I wondered if anyone know what causes this?
I use TexturePacker to make the sprite sheet, with the settings: Pixel Format: RGBA8888, Texture Format: PVR+zlib.
Here is the code for my animation, which I have in my Player class and it's iniated when it's created:
FileUtils::getInstance()->addSearchResolutionsOrder("indian_spreedsheet/HD");
// load and cache the texture and sprite frames
auto cacher = SpriteFrameCache::getInstance();
cacher->addSpriteFramesWithFile("indian_walk.plist");
#include <sstream>
// load all the animation frames into an array
const int kNumberOfFrames = 4;
Vector<SpriteFrame*> frames;
for (int i = 1; i < kNumberOfFrames; i++)
{
std::string s = std::to_string( i );
SpriteFrame* aFrame =
cacher->getSpriteFrameByName( "indian_walk" + s + ".png" );
frames.pushBack(aFrame);
}
// play the animation
auto animation = Animation::createWithSpriteFrames(frames, 0.40f);
animation->setRestoreOriginalFrame(true);
moveAnimate = Animate::create(animation);
moveAnimate->retain();
I work in Visual Studio, with Cocos2d-x version 3.3.
I can include pictures of the event if anyone feel it's needed.
Thanks in advance!
check your "indian_walk.png", is there some red color on it?
as described in the official document:
Is there a trial version?
Yes, there is a 7-day trial mode with
unrestricted features. After that period TexturePacker goes into
Essential mode. It is restricted to basic features. If you use Pro
features in this mode, you will get a warning before publishing and
some of your sprites will turn red in the output.
link is here
Using Qt5 official release --
I need to save the x,y properties of an image element. This
QObject* pic = rootitem1->findChild<QObject*>("image_objectName");
int x = pic->property("x").toInt();
gives the value the property was originally set with, but what I need is the current value after the image has been moved by the mouse. I'm probably missing something simple but I can't find any thing else on it. Really would appreciate any help, THANKS.
I have a qwt plot in my application. I want to show a small tool tip to show the value of the point at which mouse is pointed on the curve. I found that I have to use QwtPlotPicker for this, but couldn't find any proper example to implement this in my code. I am new to Qwt so it would be great if anyone could help me solve this problem.
Thanks, Rakesh.
The author himself says here:
A QwtPlotPicker gives you the current position of the mouse ( in screen and plot coordinates ). Then you need to find the closest points of your curves. You can use QwtPlotCurve::closestPoint(), but in most cases you can find a much faster implementation depending on the characteristics of your data.
When you need to compare the mouse position with the lines between the points you need the pixel position of these points ( use QwtPlot::canvasMap ).
Maybe looking at the CanvasPicker of the eventfilter example helps.
I implemented it in my own class, which is a subclass of QwtPlot. In the constructor I have the following:
QwtPlotPicker* plotPicker = new QwtPlotPicker(this->xBottom, this->yLeft, QwtPicker::CrossRubberBand, QwtPicker::AlwaysOn, this->canvas());
QwtPickerMachine* pickerMachine = new QwtPickerClickPointMachine();
plotPicker->setStateMachine(pickerMachine);
connect(plotPicker, SIGNAL(selected(const QPointF&)), this, SLOT(onSelected(const QPointF&)));
Now in my class (where the this pointer refers to) I should implement the slot onSelected(const QPointF&) which will give the plot coordinates.
I'm new to Qt development so I've being trying to research a solution to a user interface I need to design. My project is to simulate players in an online game moving around a global map. To represent the map I need to display a 2D grid, with each space in the grid representing a region of a map. I then need to display the location of each player in the game. The back-end is all fully working, with the map implemented as a 2D array. I'm just stuck on how to display the grid.
The research I have done has led me to believe a QGraphicsView is the best way to do this, but I can't seem to find a tutorial relevant to what I need. If anyone has any tips on how to implement this it would be much appreciated.
Thanks, Dan
A 2D Grid is nothing more than a set of horizontal and vertical lines. Suppose you have a 500x500 map and you want to draw a grid where the distance between the lines in both directions is 50. The sample code that follows shows you how you can achieve it.
// create a scene and add it your view
QGraphicsScene* scene = new QGraphicsScene;
ui->view->setScene(scene);
// Add the vertical lines first, paint them red
for (int x=0; x<=500; x+=50)
scene->addLine(x,0,x,500, QPen(Qt::red));
// Now add the horizontal lines, paint them green
for (int y=0; y<=500; y+=50)
scene->addLine(0,y,500,y, QPen(Qt::green));
// Fit the view in the scene's bounding rect
ui->view->fitInView(scene->itemsVBoundingRect());
You should check the QGraphicsView and the QGraphicsScene documentation as well as the corresponding examples. Also you can watch the graphics view training videos or some graphics view related videos from the Qt developer days.
Well if you have a constant grid size or even a limited number of grid sizes what i like to do is to draw a grid block in gimp or any other program and then set that as the background brush (draw only bottom and right side of the block) qt will repeat the image and will give you a full grid. I think this is good for performance too.
This is the grid image i used in one of my programs it's 10x10 pixels.
Then call QGraphicsScene setBackgroundBrush as the follwing:
scene->setBackgroundBrush(QBrush(QPixmap(":/grid/grid10.png")));
The more native way is this:
scene = self.getScene() # Your scene.
brush = QBrush()
brush.setColor(QColor('#999'))
brush.setStyle(Qt.CrossPattern) # Grid pattern.
scene.setBackgroundBrush(brush)
borderColor = Qt.black
fillColor = QColor('#DDD')
rect = QRectF(0.0, 0.0, 1280, 720) # Screen res or whatever.
scene.addRect(rect,borderColor,fillColor) # Rectangle for color.
scene.addRect(rect,borderColor,brush) # Rectangle for grid.
Sorry by PyQt...
Suppose a scene is set to the graphicsview then simply below one line will show the grid.
ui->graphicsView->scene()->setBackgroundBrush(Qt::CrossPattern);
There several other values can be passed for ex: Qt::Dense7Pattern
These are members of enum BrushStyle, just click on any used value in Qt creator and it will take you to the enum declaration where you can see all other possible values.
PS:
A scene can be set like this:
ui->graphicsView->setScene(new QGraphicsScene());