Learn what Felgo offers to help your business succeed. Start your free evaluation today! Felgo for Your Business

Forums

OverviewFelgo 1 Support › Problems with cocos-renderer

Viewing 12 posts - 1 through 12 (of 12 total)
  • Author
    Posts
  • #3987

    Heini

    Hi,
    i am testing the Felgo-Engine and have some problems with the cocos-renderer. Running my app with the cocos-renderer enabled, i´m getting a message like “Get data from file (\\//myAppDrawer/qml/box.png) failed!” The message appears every time, when Felgo is trying to load a resource (image, sound, particleeffect…), even if the requested files ARE in that drawer (wondering about the slashes/backslashes at the beginning of the filestring…) 😮 . Lounching the app with the standart qml renderer and disabling cocos-renderer works fine (but without particles).
    Another problem is, that lounching a demo-app (like StackTheBox) even the sound does not work. I am working on a Compaq Presario Laptop with Windows 7. Any suggestions, what i am doing wrong? Thanks for your answer!

    #4021

    Christian
    Felgo Team

    Hi,
    thank you for your request! For finding the source of the issues, it would be great if you could provide the following detailed information to nail the problem down:

    1. How did you define the source url of the Image? Did you define it with a relative path like “../img/box.png”?

    2. In which demo or examples project does the sound not work (i.e. which sound file exactly? is it a .wav, or .mp3?). Does the sound only not work with the cocosRenderer, or also with QmlRenderer?

    cheers,
    Chris

    #4022

    Heini

    Hi Chris,

    1. The problem appears by using relative paths. When i try the same thing using absolute paths, cocosrenderer works fine. Is there a possibility to get the absolute application path with qml?

    2. Sound does not work neighter on cocosrenderer nor on standart qml renderer. No matter the file is wav or mp3. (in my example the boxCollision.wav delivered with StackTheBox-Demo). But the console gives me the following feedback: Sound.play() – is this a loop?

    Greetings

    #4023

    Christian
    Felgo Team

    Hi,
    alright, so let’s see..

    1. You can use Qt.resolvedUrl() which returns an absolute path from a relative one. However, the images should work without this function, unless you are setting the url from a component in a different directory, as QML would then assume the path to be relative to your calling component. Here is the doc for the resolvedUrl function:[url] http://doc.qt.digia.com/4.7-snapshot/qml-qt.html#resolvedUrl-method%5B/url%5D

    It would be great if you could copy the relevant code here in the forum, so we can have a detailed look into the issue.

    2. This is a bug in our current SDK v0.9.4 – fortunately it is fixed with the new version 0.9.5 which is coming in the next days! We’ll send the update note on twitter, email and detail the changes in a blog post – besides the bug fixes, there’s a lot of cool stuff in this release, so I hope you can wait for the fix a couple of days.

    cheers,
    Chris

    #4024

    Heini

    Hi Chris,

    even Qt.resolvedUrl() does not work. CocosRenderer is only able to load my recources by passing an absolute filepath. Strange that the relative paths work with standardQmlRenderer. Here is the code from my main.qml and box.qml:

    main.qml:

    import VPlay 1.0
    import QtQuick 1.1
    import Box2D 1.0
    import "entities"
    
    GameWindow {
    
        id: window
    
        EntityManager{
           id: entityManager
           entityContainer: scene
        }
    
        Scene
        {
            id: scene
    
            Component{
                id: mouseJoint
                MouseJoint{
                    maxForce: 30000
                    dampingRatio: 1
                    frequencyHz: 2
                }
            }
    
            MouseArea{
                anchors.fill: parent
    
                property Body selectedBody: null
                property MouseJoint mouseJointWhileDragging: null
    
                onPressed: {
                    selectedBody = physicsWorld.bodyAt (Qt.point (mouseX,mouseY));
                    console.debug("selected body at position", mouseX, mouseY, ":", selectedBody);
                    if (selectedBody)
                    {
                        mouseJointWhileDragging = mouseJoint.createObject(physicsWorld)
                        mouseJointWhileDragging.target = Qt.point (mouseX, mouseY)
                        mouseJointWhileDragging.targetBody = selectedBody
                        mouseJointWhileDragging.world = physicsWorld
                    }
                }
                onPositionChanged: {
                    if(mouseJointWhileDragging)
                    {
                        mouseJointWhileDragging.target = Qt.point (mouseX, mouseY)
    
                    }
                }
                onReleased: {
                    if (selectedBody)
                    {
                        selectedBody = null
                        if (mouseJointWhileDragging)
                            mouseJointWhileDragging.destroy()
                    }
                }
            }
    
            PhysicsWorld{
               id: physicsWorld
                gravity.y: -9.81
            }
    
            Box {
                x: scene.width/2
                y: 50
            }
    
    
            Timer{
                id: timer
                interval: Math.random()*3000+2000
                running: true
                repeat: true
                onTriggered: {
                    var newEntityProperties = {
                        x: Math.random()*(scene.width-50)+50,
                        y: 50,
                        rotation: Math.random()*360
                    }
    
                    entityManager.createEntityFromUrlWithProperties(Qt.resolvedUrl("entities/Box.qml"), newEntityProperties);
    
                    interval = Math.random()*3000+2000
                    scene.createdBoxes++
                    timer.restart()
                }
            }
    
            property int createdBoxes: 1
    
            Text
            {
                text: "Boxes: " + scene.createdBoxes
                color: "white"
                z: 1
            }
    
            Wall{
                //bottom wall
                height: 20
                anchors {
                    bottom: scene.bottom
                    left: scene.left
                    right: scene.right
                }
            }
    
            Wall{
                //left wall
                width: 20
                anchors{
                    top: scene.top
                    bottom: scene.bottom
                    left: scene.left
                }
            }
    
            Wall
            {
                //right wall
                width: 20
                height: scene.height
                anchors.right: scene.right
            }
    
            Wall
            {
                //top wall
                height: 20
                width: scene.width
                anchors{
                    top: scene.top
                }
                color: "red"
    
                onCollidedWithBox: {
                    entityManager.removeEntitiesByFilter(["box"]);
                    scene.createdBoxes = 0;
                }
            }
        }
    }
    

    box.qml:

    [// import QtQuick 1.0 // to target S60 5th Edition or Maemo 5
    import QtQuick 1.1
    import VPlay 1.0
    import "../particles"
    
    EntityBase
    {
    
        entityType: "box"
    
    
        Image{
            id: boxImage
            source: Qt.resolvedUrl("box.png") //does not work
            //source: "box.png" //does not work
            anchors.fill: boxCollider
    
        }
    
        BoxCollider{
            id: boxCollider
            width: 32
            height: 32
            anchors.centerIn: parent
    
            friction: 1.6
            restitution: 0
            density: 100
    
            fixture.onBeginContact: {
                collisionSound.play();
                collisionParticleEffect.start();
    
            }
        }
    
        Sound{
            id: collisionSound
            source: "boxCollision.wav"
        }
    
        SmokeParticles{
            id: collisionParticleEffect
        }
    }
    

    The directory of box.qml is named “entities”, contains box.qml, box.png and boxCollision.wav. Its a subdirectory of the directory containing the main.qml

    Greetings

    #4025

    Christian
    Felgo Team

    Hi,
    did you put the entities directory into the qml directory of the project?

    When I tried your code, it worked fine on my Windows7 machine with the following folder structure:
    .pro file
    qml
    qml/entities
    qml/entities contents: Box.qml, Wall.qml, box.png, boxCollision.wav

    Could you try the following simple example, after starting a new Felgo project and and copying the box.png into the qml direcory:

    main.qml:

    
    import VPlay 1.0
    import QtQuick 1.1
    
    GameWindow {
      width: 800
      height: 600
    
      Image {
        source: "box.png"
      }
    }
    

    Do the other demo games (like Squaby and Chicken Outbreak) also not show any images with cocos renderer?

    cheers,
    Chris

    #4026

    Heini

    Hi Chris,

    i tried your example above and the other demos, all with the same result: cocos-renderer only works with absolute paths.
    Then i found another issue:
    As i am a c++ coder, i prefer to switch the qml-files on the c++-side. Using normal QML i do this by calling QDeclarativeView::setSource(QUrl url).
    But when i try to call the equivalent function FpsQMLViewer::setSource(QUrl url) in VPlay, it results in several linker-errors and the following compiling log:

    18:55:20: Führe Build-Schritte für Projekt VPlay_Test aus…
    18:55:20: Unveränderte Konfiguration, qmake-Schritt wird übersprungen.
    18:55:20: Starte “C:\QtSDK\QtCreator\bin\jom.exe”
    Copying application data…
    11 Datei(en) kopiert

    jom 1.0.6 – empower your cores

    “\\USER-PC\Users\User\Qt-Projects\VPlay_Test”
    CMD.EXE wurde mit dem oben angegebenen Pfad als aktuellem Verzeichnis gestartet.
    UNC-Pfade werden nicht untersttzt.
    Stattdessen wird das Windows-Verzeichnis als aktuelles Verzeichnis gesetzt.
    C:\QtSDK\QtCreator\bin\jom.exe -nologo -j 2 -f Makefile.Debug
    cl -c -nologo -Zm200 -Zc:wchar_t- -Zi -MDd -GR -EHsc -W3 -w34100 -w34189 -DUNICODE -DWIN32 -DQT_LARGEFILE_SUPPORT -DQT_DECLARATIVE_DEBUG -DQT_DLL -DQT_DECLARATIVE_LIB -DQT_GUI_LIB -DQT_CORE_LIB -DQT_HAVE_MMX -DQT_HAVE_3DNOW -DQT_HAVE_SSE -DQT_HAVE_MMXEXT -DQT_HAVE_SSE2 -DQT_THREAD_SUPPORT -I”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtCore” -I”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtGui” -I”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\QtDeclarative” -I”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include” -I”c:\QtSDK\Desktop\FelgoSDK\include” -I”qmlapplicationviewer” -I”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\include\ActiveQt” -I”debug” -I”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\mkspecs\win32-msvc2010″ -Fodebug\ @C:\Users\User\AppData\Local\Temp\klasse.obj.4364.94.jom
    klasse.cpp
    Copying application data…
    11 Datei(en) kopiert
    link /LIBPATH:”c:\QtSDK\Desktop\Qt\4.8.1\msvc2010\lib” /NOLOGO /DYNAMICBASE /NXCOMPAT /DEBUG /MANIFEST /MANIFESTFILE:”debug\VPlay_Test.intermediate.manifest” /SUBSYSTEM:WINDOWS “/MANIFESTDEPENDENCY:type=’win32′ name=’Microsoft.Windows.Common-Controls’ version=’6.0.0.0′ publicKeyToken=’6595b64144ccf1df’ language=’*’ processorArchitecture=’*'” /OUT:debug\VPlay_Test.exe @C:\Users\User\AppData\Local\Temp\VPlay_Test.exe.4364.2528.jom
    Bibliothek “debug\VPlay_Test.lib” und Objekt “debug\VPlay_Test.exp” werden erstellt.
    MSVCRTD.lib(cinitexe.obj) : warning LNK4098: Standardbibliothek “libcmt.lib” steht in Konflikt mit anderen Bibliotheken; /NODEFAULTLIB:Bibliothek verwenden.
    VPlayd.lib(textfielddelegateqobject.obj) : warning LNK4217: Lokal definiertes Symbol “??0CCTextFieldDelegate@cocos2d@@QAE@XZ (public: __thiscall cocos2d::CCTextFieldDelegate::CCTextFieldDelegate(void))” wurde in “public: __thiscall TextFieldDelegateQObject::TextFieldDelegateQObject(class QObject *)” (??0TextFieldDelegateQObject@@QAE@PAVQObject@@@Z)-Funktion importiert.
    VPlayd.lib(textfielddelegateqobject.obj) : warning LNK4217: Lokal definiertes Symbol “??0CCPoint@cocos2d@@QAE@MM@Z (public: __thiscall cocos2d::CCPoint::CCPoint(float,float))” wurde in “void __cdecl cocos2d::`dynamic initializer for ‘CCPointZero”(void)” (??__ECCPointZero@cocos2d@@YAXXZ)-Funktion importiert.
    VPlayd.lib(textfielddelegateqobject.obj) : warning LNK4217: Lokal definiertes Symbol “??0CCSize@cocos2d@@QAE@MM@Z (public: __thiscall cocos2d::CCSize::CCSize(float,float))” wurde in “void __cdecl cocos2d::`dynamic initializer for ‘CCSizeZero”(void)” (??__ECCSizeZero@cocos2d@@YAXXZ)-Funktion importiert.
    VPlayd.lib(textfielddelegateqobject.obj) : warning LNK4217: Lokal definiertes Symbol “??0CCRect@cocos2d@@QAE@MMMM@Z (public: __thiscall cocos2d::CCRect::CCRect(float,float,float,float))” wurde in “void __cdecl cocos2d::`dynamic initializer for ‘CCRectZero”(void)” (??__ECCRectZero@cocos2d@@YAXXZ)-Funktion importiert.
    main.obj : error LNK2019: Verweis auf nicht aufgelöstes externes Symbol “”public: __thiscall Klasse::Klasse(class QObject *,class QDeclarativeView *)” (??0Klasse@@QAE@PAVQObject@@PAVQDeclarativeView@@@Z)” in Funktion “_main”.
    debug\VPlay_Test.exe : fatal error LNK1120: 1 nicht aufgelöste externe Verweise.
    “\\USER-PC\Users\User\Qt-Projects\VPlay_Test”
    CMD.EXE wurde mit dem oben angegebenen Pfad als aktuellem Verzeichnis gestartet.
    UNC-Pfade werden nicht untersttzt.
    Stattdessen wird das Windows-Verzeichnis als aktuelles Verzeichnis gesetzt.
    “\\USER-PC\Users\User\Qt-Projects\VPlay_Test”
    CMD.EXE wurde mit dem oben angegebenen Pfad als aktuellem Verzeichnis gestartet.
    UNC-Pfade werden nicht untersttzt.
    Stattdessen wird das Windows-Verzeichnis als aktuelles Verzeichnis gesetzt.
    command failed with exit code 1120
    command failed with exit code 2
    18:55:25: Der Prozess “C:\QtSDK\QtCreator\bin\jom.exe” wurde mit dem Rückgabewert 2 beendet.
    Fehler beim Erstellen des Projekts VPlay_Test(Ziel: Desktop)
    Bei der Ausführung von Build-Schritt ‘Make’

    Maybe that´s the reason, why the relative paths does not work: the windows-path seems to be set as current path. Do you know, how to solve this?

    Thank you and greetings!

    #4027

    Christian
    Felgo Team

    Hi,

    your build errors look like an old issue of Windows regarding this Microsoft support article: http://support.microsoft.com/kb/156276/de
    However, that issue should be fixed since Windows XP so with Win7 you should be fine. Is the UNC-path error also appearing if you create a normal (non-Felgo) QML project?

    Another suggestion would be, to avoid any special characters in paths (so no underscores, whitespaces, etc.) and if you could try an empty Felgo project from there? Your path looks like you have installed the project on a network drive “\\USER-PC\Users\User\Qt-Projects\VPlay_Test”?

    Regarding your setSource issue:
    The only supported function to set the entry qml file is by using

    
    // the default mainQmlFileName is qml/main.qml - if you want to change the entry qml file, change it here before startApplication() is called
    vplayApplication.setMainQmlFileName("qml/SquabyMain.qml");
    

    If you do not want to import other QML files statically in this main.qml file, you can load them with the QML Loader element.

    cheers,
    Chris

    #4028

    Heini

    Hi Chris,

    thank you for putting me in the right direction! Finally I was able to solve this strange issue, that was caused by “Virtual Box”, witch is also installed on my system. After disabling the Virtual-Box-Network-Connection everything is fine and cocos-renderer now works also with relative paths.

    Another question:
    Let´s say, we have a game with 50 levels, each one with another background-graphics. With the QML-Loader i can load them dynamically when they are needed. Is there also a possibility to delete unused ressources from memory? I.e. when the player reaches level 50, I don´t wanna hold 50 backgrounds in memory.
    Sorry about this stupid question, but I´m a QML-noob. 😉

    Greetings
    Heini

    #4029

    Christian
    Felgo Team

    Hi Heini,
    that’s great to hear that your issue could be resolved!

    Regarding the QML Loader element:
    As soon as the source or sourceComponent property of the Loader element is changed, the old resources get removed from memory. You can check that by adding

    Component.onDestruction: { console.debug("Destructor called, this item is removed from memory...") }

    to the item you load dynamically. When using the Loader element, please also add a call of [codeloadItemWithCocos()] which is defined in GameWindow. This is currently required to be done manually, because you might not always want to load the loaded item immediately with cocosRenderer. This is a complete example, like used in the SquabyMain example to load the CreditsScene dynamically:

    Loader {
        //    source: "otherScenes/CreditsScene.qml" // set this source whenever you want to load the Scene dynamically
        id: creditsSceneLoader
    
        onLoaded: {
          console.debug("finished loading CreditsScene")
          loadItemWithCocos(creditsSceneLoader.item)
        }
      }
    

    cheers,
    Chris

    #4030

    Heini

    Hi Chris,

    this works, thanks for your help!!

    Bye

    #4031

    Christian
    Felgo Team

    Hi Heini,
    great that it works & you’re welcome!

    If you have any further questions, just ask them here – probably also other developers have the same questions, and we can incorporate them directly into our documentation as well.

    I also wanted to point you to the last blog post in case you missed it: http://felgo.com/2012/10/25/sdk-update-symbian-meego-support-and-free-pro-license-promotion/ – if you manage to submit your game until the 11th of September, you will get a 1-year pro license for free. So keep the questions coming 🙂

    Cheers,
    Chris

Viewing 12 posts - 1 through 12 (of 12 total)

RSS feed for this thread

You must be logged in to reply to this topic.

Qt_Technology_Partner_RGB_475 Qt_Service_Partner_RGB_475_padded