CCMenuItemImage builded with cocosbuilder can't call my methods - cocos2d-iphone

So I built a CCMenuItemImage with cocosbuilder in my cocosbuilder project and use it later in my project.
However, the responding method is never called.

Go up to the Document menu and make sure "JavaScript Controlled" is unchecked.
I was having a really hard time with this. CCBControlButtons called their selectors, but CCMenuItemImages didn't. Changed that setting and it's working now.

You didn't provide very much information that allows us to help. However, I recently did the same thing with my app so perhaps I can give you some ideas on where to look. First, is the CCMenu its own root node (separate file) or is it a child of a CCLayer in your CocosBuilder file?
In the first scenario, the CCMenu (and CCMenuItemImage) is a separate node file, then you would link it to your game layer code with the statement:
CCMenu *menu = [CCBReader nodeGraphFromFile:#"filename.ccbi" owner:self];
Then in the Cocosbuilder program, where you type in the name of the method the CCMenuItemImage links to, make sure you select "Owner" instead of "Document root".
The second scenario is where your Cocosbuilder file is a CCLayer and the CCMenu is a child of that layer, which might be a more likely scenario. If you successfully loaded your ccb file with
CCScene *scene = [CCBReader sceneWithNodeGraphFromFile:#"filename.ccbi"]; (might need to double-check that one, I am not at my XCode)
Then, in Cocosbuilder when you type in your CCMenuItemImage method name, select "Document Root" to link this to your code.
Then in your game layer's code, you should have the same method as you typed into Cocosbuilder. So if your game layer's method is:
-(void)pressedButton:(id)sender {
CCLOG(#"Button pressed!");
}
Then you need to have the same method
pressedButton:
linked to that button in Cocosbuilder.
Hope this helps.

well, that's happened to me too...
the solution is
first, u have to press enter after u've typed the selector field..
secondly, u have to publish (I do more than once).
for your info.... when u saved cocosbuilder project (cmd + s), u will not save the entire project... u'll only save current scene....
so, just in case u should save and publish on every scene u worry..
last tip (i don't know the different though), I chose document root (not owner ) :D
may this tips help you bro!

Related

How insert multiple FormView in View of an SDI application

I searched on the forum and I don't find a solution for my issue. So I hope you can help me :)
I work on a personal project for SFC designing (Sequential functional chart) and I'm working with visual studio in SDI(I'm using MFC library). If you see the "design" of an SFC you can see the different elements needed to compose this. So you can find Step, Transition, and more. If I take a step for explaining my issue, after double click on the step a popup dialog is opened with the elements to define this step (actions on this step, and more). The issue is here, I can't see two or more step elements at the same time. I want to reuse the existing concept on other software, see this.
Step close
Step open
Dialog to add
My question is, how I can implement a dialog with my graphic element in mainframe (In this case, a step)? I don't know how I can insert a dialog with my element, I think I need to use CFormView, but I don't know.
This dialog needs to be resizable and reduce directly by the step graphic.
any idea?
Thank you in advance! Sorry for my English ..
Sorry, I think my request is not clear .. (Thank you for your answer)
The context, it's an SDI application with the Document/View architecture. Actually the view is derived from CScrollView.
So, in the document class, you have the different lists of components for make SFC (Steps, transitions and symbols ..). I'm working today on Step element.
The user inserts a new step, the step is draw on the view like this :
enter image description here
And now the user want change the events on this Step, for this after double click on the step the events editor is opened at right of step draw, like this :
enter image description here
For this, I've created a new dialog resource and create the class by wizard in CForwView derived class. In step attribute, you can find one instance of this derived class (The derived class of dialog).
But this doesn't work correctly, I think my method is bad. At the first try, I have sent the pointer of the current document to the "CFormView::Create" function for having the "Save" button active with the focus on the FormView. But after destroying the step, the instance of FormView is destroyed and the document with the instance of formview ...
No problem, you can use "Create" within CCreateContext a null pointer. But with the document or without I have a lot of problems (graphic design not correct in FormView, regularly (not systematic I have assert fail on Proc exchange (for differents reason)). But the "concept" is good, the editor follows the draw if I scroll, I can open or close the editor at any time and on any elements.
For the old capture, it's my SFC designer "model". My application is a complement to this application, so I want a similar design. I don't know how work my model application ..
On my application all is draw by MFC GDI, I don't use ActiveX or other tools.
So what is the correct way to implement one instance of editor by instance of step ?
For the implementation on this FormView I have :
- Make new dialog in ressource
- Create a derived class of CFormView with the created dialog
- Add one instance in attributes of Step element
- "OnDbClickOnStep" -> Call "Create" with the good position / size, pointer of mainview (in my case the CSrollView derived class)
- Done, FormView inserted in a mainview, I can edit my step events.
? Not done, I lost save button and other function linked to the document with the focus on a control in FormView. The app want a document with this view, how to override this ?
? Error in Proc exchange, for different reason...
You have an idea ?
You normally don't draw anything in the "main frame" (or the "MDI clild frames", in the case of a MDI application), this is done by the library, and imo sufficiently so. You display your data in a CView-derived class.
CView is the base class of all other MFC view classes. It's a simple graphical class - you need to paint it yourself in the OnDraw() member.
CScrollView is a descendant of CView, adding scrolling functionality (scroll-bars are automatically displayed if the scrollable area is bigger than the visible window area).
CFormView is a descendant of CScrollView, displaying a dialog resource-script, containing "controls" (edit-boxes, check-boxes, images, ActiveX etc).
As in your case the "controls" won't be initially known (except maybe for some few special cases) and rather programatically created, the resource script will most likely be empty, so using either CFormView or CScrollView will basically be the same. I would suggest starting with CFormView, and "downgrade" it to CScrollView if CFormView is not necessary or causes you troubles.
What are those "Step" items shown in the pics? ActiveX controls, child dialogs maybe? These work best as child controls on a dialog window. Are they already implemented, or they are just pics of some other software? Btw ActiveX is a way to define controls that can be used in other projects too, without having to include them in the project source.

How to alternate between two scenes in cocos2d-x?

I'm creating a game using Cocos2d-x. I'm currently creating a gameover menu, in that menu I need to be able to switch to both my menuscene and my gamescene (When I say switch to gamescene I only really only mean "to restart" the game). But circular dependencies stop me from being able to do this.
MenuScene needs to be able to useGameScene::create() in order to switch to the gamescene and the gameover menu needs to be able to use both of GameScene::create() or its restart funtion and MenuScene::create() which is giving me circular dependency problems
I can't separate my gameover menu to it's own file as I still need the GameScene dependency and GameScene would need gameover.
I can't combine them as GameScene then needs to depend on MenuScene
So my question is: How do I alternate between two scenes in cocos2d-x c++.
I read somewhere about pushing and popnig scenes in Director, but I don't really understand how that works, or if I could use that for my purpose.
Thank you in advance!
EDIT:
Now that I think about it, could I not just push mMenuScene to Director before switching to GameScene? That should work if I understand that push/pop mechanic correctly.
I think you might have a misconception of how complex this is, using the way I provided below you can and should definitely split your game over scene into its own file.
The scene replace is easy enough, just use the code below:
Including your file:
#include "MainGameScene.h"
Creating and switching scenes in your onClickListener:
auto gameOverScene = GameOverScene::createScene();
// use code below for hard replace
Director::getInstance()->replaceScene(gameOverScene );
// or use code below for transition fade replace
Director::getInstance()->replaceScene(TransitionFade::create(1, gameOverScene , Color3B(255, 255, 255)));
As for the restart functionality. I usually provide a callback to my game over scene that I call when the restart button has been clicked. Not that I ever swap out my scene completely for a mobile game over scene, but I still do it the same way regardless. So lets do steps (This assumes you seperated your game over scene into it's own file named GameOverScene :) ).
Store a function pointer in your GameOverScene.h to your reset method in MainGameScene:
std::function<void()> _resetCallback;
Set your function pointer from the main game scene, before running with the GameOverScene.
auto gameOverScene = GameOverScene::createGameOverScene();
gameOverScene->setResetCallback(std::bind(&MainGameScene::reset, this));
When your reset button is clicked, call the _resetCallback
void GameOverScene::onResetClicked(Ref* sender)
{
_resetCallback();
}
This should provide you with all the functionality you need to set up a what you want as well as remove the circular dependency that you have. I have used this way many times before and it always works. Let me know if this solution works for you.

Qt Creator 2.8.1 Qt 5.1.1 Qt Designer Linux Show a new Form

I am a beginner with Qt - so hopefully this will be an easy question to answer. I have a reasonable amount of experience with C++, that part is not a problem
The purpose of my application is to do code generation, initially to make header & implementation files for classes. I quite like the Class wizard on Code::Blocks, but I reckon I can do a lot more.
I have a main Widget which has a tabWidget & some lineEdit's & some pushButtons. To preview what will eventually be in the file, I have created a new Form, with a TextBrowser in it. The new Form entry appears in the .pro file.
I would like to have the new Form displayed when I press the pushButton, & I am intending to write text in the TextBrowser based on the contents of the lineEdit's in the main Widget.
I have been looking through the documentation all afternoon, but most of the examples show either a main widget or a Form by itself. I have seen the example of the Class Wizard (which is nearly what I want to do), but I would rather a tabWidget interface. Being able to open a Form from a button is a pretty basic thing to be able to do.
For some reason, the examples page in my QtCreator help doesn't show any examples - previous versions had heaps of examples. Not sure why that is.
Do I have my terminology mixed up - should I have a Dialog rather than a Form? Not sure what the difference is.
Apologies in advance if all this is in the documentation somewhere, I seem to spend hours trolling through it, so maybe someone could provide some links - that would be great.
Suppose the new form you created along with with header and cpp file is mynewform.h, mynewform.cpp and mynewform.ui
Now include mynewform.h in your mainwindow class,
and create an object of the class
mynewform myform;
In the clicked slot of pushbutton just type:
myform.show();
or
myform.exec(); //(if you want a blocking call)

cocos2d cctransitionpageturn

I have 2 problem on CCTransitionPageTurn. I target to work on a layer with topLayer and pageLayer. Where topLayer always on top and have menuItem to change page. And pageLayer be content with TurnPage effect.
Since I cannot add a CCScene over another CCScene (i.e. MainScene(CCScene) -> PageScene(CCScene) -> TopLayer(CCLayer) ). So, I think the design will be doing turn page effect on CCLayer (i.e. MainScene(CCScene) -> PageLayer(CCLayer) -> TopLayer(CCLayer) ). But this time CCTransitionPageTurn only support `CCScene. Any advice which is a better approach?
I see CCTransitionPageTurn is turning page at right-bottom corner (forward or backward). But how can I make it at left-bottom corner? Something like flip-X.
Just use CCPageTurn3D action on the layers, which is actually what drives the CCTransitionPageTurn.
Then, to make the page turn from another corner, just subclass CCPageTurn3D. Open the source file of CCPageTurn3D, and you'll see that it implements a single method. Copy that method to your new subclass, and alter it to make the action take place from any corner you like. If you can't accomplish this, just ask, and I'll help you figure it out.
(Pro Tip: when I was new to cocos2d, I'd always forget it's open source, so don't forget that! I figured out this answer by checking the cocos2d source code!)

QT4 qlistview save icon position moved by hand for the next time

I'm developing an app with qt4.3 which opens a window with a bunch of icons loaded from .desktop files. It tries to emulate a file browser but without file browsing... I mean, you can double click and open an app or drag the icons to an other position not necessary attached to the grid.
I'm using a qdirmodel and a qlistview in "icon mode".
My problem is that I can't save the position of the icons once I moved them. Every time I restart the app, I get the icons loaded in the default position.
I can't find any way to know the position of an item or move an item to a position.
What I should do? Do I have any chance?
Thanks!
I'm sure, you can save item's position. You should read about save session qt.
This is official qt doc about Session Management Session Management
And also I'll advice to read qt's possibility save settings QSettings
After looking at the qlistview code I found that I can also inherit the qlistview class and convert to public a couple of protected functions which return the item position and move the item to a position. Thanks anyway!!