Static assert while addChild to camera

Static assert while addChild to camera
0

Hi…

when i attach a label object to the camera, static assert appear… clipPos.w != 0.0

this->getDefaultCamera()->addChild(myLabelObj);

this does not happens when i attach a menu item… why

Thanks.

Show us what you are doing.

Image attached

I’m sorry, post code, not screenshots? How can I try anything?

scnPrologue.cpp (2.1 KB) scnPrologue.h (2.2 KB)

You can post code by surrounding it in 3 backticks.

Like this

Ok, sorry about that, here is
ScnPrologue.h

//Prologo:
//	Static assert en L.36 scnPrologue.cpp
//  Puse pregunta en el foro, si no hay respuesta, usar el modelo B (esta en el cuaderno)

#ifndef __SCNPROLOGUE_H__
#define __SCNPROLOGUE_H__

#pragma once

#include <cocos2d.h>

class scnPrologue : public cocos2d::Scene {

private:

	//----------------- Archivos de video
	//const char* CLIP0_FILE{ "Images/MainMenu/vid_clip0.mp4" };
	//const char* CLIP1_FILE{ "Images/MainMenu/vid_clip1.mp4" };
	//const char* CLIP2_FILE{ "Images/MainMenu/vid_clip2.mp4" };

	//----------------- Archivos de shot
	const char* SHOT0_FILE{ "Images/Prologue/img_shot0.jpg" };
	const char* SHOT1_FILE{ "Images/Prologue/img_shot1.jpg" };
	const char* SHOT2_FILE{ "Images/Prologue/img_shot2.jpg" };
	const char* SHOT3_FILE{ "Images/Prologue/img_shot3.jpg" };

	
	//----------------- Archivos de imagen para botones de control
	//Saltar secuencia y siguiente (ambos usan el mismo sprite pero con distinta orientación)
	const char* BCONTROL_NORMAL{ "Images/Shared/btn_triangle_normal.png" };
	const char* BCONTROL_PRESSED{ "Images/Shared/btn_triangle_pressed.png" };	

	//----------------- BGM
	const char* BGM_FILE{ "Sounds/BGM/bgm_prologue.mp3" };

	//----------------- Fuentes
	const char* TXTFONT_FILE{ "Fonts/fnt_space2.ttf" };


	//----------------- Presets
	//const cocos2d::Vec2 CLIP0_POS = cocos2d::Vec2(0, 0);
	//const cocos2d::Vec2 CLIP1_POS = cocos2d::Vec2(0, 0);
	//const cocos2d::Vec2 CLIP2_POS = cocos2d::Vec2(0, 0);

	const cocos2d::Vec2 SKIPBTN_POS = cocos2d::Vec2(0, 0);
	const cocos2d::Vec2 NEXTBTN_POS = cocos2d::Vec2(0, 0);
	const cocos2d::Vec2 SHOT0_POS = cocos2d::Vec2(0, 0);
	const cocos2d::Vec2 SHOT1_POS = cocos2d::Vec2(0, 0);
	const cocos2d::Vec2 SHOT2_POS = cocos2d::Vec2(0, 0);

	//Elementos
	cocos2d::Vector<cocos2d::MenuItem*> uiItems{};

	cocos2d::Label* comments{};					// Object declaration

	cocos2d::Sprite* _shot0{};
	cocos2d::Sprite* _shot1{};
	cocos2d::Sprite* _shot2{};

	

	void startScene();
	void onPress_Next();
	void onPress_Skip();


public:

	static cocos2d::Scene* createScene();
	virtual bool init();

	// implement the "static create()" method manually
	CREATE_FUNC(scnPrologue);
};

#endif

scnPrologue.cpp

#include "scnPrologue.h"
#include "SimpleAudioEngine.h"


USING_NS_CC;

Scene* scnPrologue::createScene() {
	return scnPrologue::create();
}

// Print useful error message instead of segfaulting when files are not there.
static void problemLoading(const char* filename) {
	printf("Error while loading: %s\n", filename);
	printf("Depending on how you compiled you might have to add 'Resources/' in front of filenames in scnPrologue.cpp\n");
}

// on "init" you need to initialize your instance
bool scnPrologue::init() {
	if (!Scene::init())	return false;

	//1 - Definitions
	//cocos2d::Camera* camara = this->getDefaultCamera();
	MenuItemImage* itmNext = MenuItemImage::create(BCONTROL_NORMAL, BCONTROL_PRESSED, [&](Ref* pSender) { onPress_Next(); });
	MenuItemImage* itmSkip = MenuItemImage::create(BCONTROL_NORMAL, BCONTROL_PRESSED, [&](Ref* pSender) { onPress_Skip(); });
	Menu* controlsMenu = Menu::createWithArray(uiItems);
	
	comments = Label::createWithTTF("AA", TXTFONT_FILE, 24);	//Definition for label object
	
	_shot0 = cocos2d::Sprite::create(SHOT0_FILE);
	_shot1 = cocos2d::Sprite::create(SHOT1_FILE);
	_shot2 = cocos2d::Sprite::create(SHOT2_FILE);


	//2 - Adjustment
	uiItems.pushBack(itmNext);
	uiItems.pushBack(itmSkip);
	this->getDefaultCamera()->addChild(controlsMenu);			//This line works fine

	this->getDefaultCamera()->addChild(comments);				//This line produces assert exception

	this->addChild(_shot0, 0);
	this->addChild(_shot1, 0);
	this->addChild(_shot2, 0);

	//3 - Configuraciones iniciales
	this->getDefaultCamera()->setPosition(cocos2d::Vec2(0, 0));
	itmNext->setPosition(NEXTBTN_POS);
	itmSkip->setPosition(SKIPBTN_POS);
	_shot0->setPosition(SHOT0_POS);
	_shot1->setPosition(SHOT1_POS);
	_shot2->setPosition(SHOT2_POS);


	//4 - Inicio
	startScene();
	return true;
}


//Inicia la escena
void scnPrologue::startScene() {
	//CocosDenshion::SimpleAudioEngine* soundEngine = CocosDenshion::SimpleAudioEngine::getInstance();
	//soundEngine->playBackgroundMusic(BGM_FILE, true);

}

void scnPrologue::onPress_Next() {

}

void scnPrologue::onPress_Skip() {

}