QT Mobile Application Development (V): Scene switching
The previous article talked about how to use Qtquick to achieve brilliant particle effects. The advent of particle effects can give developers a chance to develop a personalized interface that can create many other interesting interfaces later. It is also suitable for mobile platforms such as Android and iOS. So that your program becomes more interesting!
Original article, against undeclared references.
Original Blog address:http://blog.csdn.net/gamesdev/article/details/34840415
This time I'll show how I can switch between scenarios when I'm actually applying development.
The switching of scenes is an architectural problem, there are a lot of implementations, and QT Quick provides a lot of useful classes for us to switch scenes. In the QML. Scene switching is essentially hiding an interface class. and the other interface class shows the method. The following code is a simple example:
Import QtQuick 2.2import qtquick.controls 1.1applicationwindow{visible:true width:640 height:480 Title:qs Tr ("Hello World") Item {id:scene_1 visible:true anchors.fill:parent Text { Anchors.centerIn:parent textFormat:Text.RichText text:qstr ("
The demo effect of the program is as follows:
The first occurrence is the left scene, when the mouse clicks the window, it will pop up the right scene. The red text will also disappear.
This example uses the Visible property of item, sets the visible of the original item to False, and then sets the visible of the item to true to achieve the purpose of the scene switch.
A scene switching is also very easy, want to use some special effects words. It is necessary to give full play to the thinking of developers, so that the interface becomes colorful!
Here's how I use the particle system I talked about in my previous blog post to achieve brilliant scene switching effects:
Here's the code for the implementation:
Import QtQuick 2.2import qtquick.controls 1.1import qtquick.particles 2.0applicationwindow{visible:true width:640 height:480 title:qstr ("Test scene Toggle") Item {id:scene_1 visible:true Anchors.fill:paren T Text {anchors.centerIn:parent textFormat:Text.RichText text:qstr ("&L T;h1><font Color=red> This is the first scene </color>In my production of
Recrefer=se_d_%e5%90%83%e8%8d%af%e4%ba%86#btn-install-now-log "> The first independent game" Take Medicine ", I carefully designed a fun way to switch between scenes: First, with about 6000 capsules covering the main main scene. Then in the next layer set the corresponding layer of visible, wait until the capsule disappears to present the next scene.
articleid=34840415 "> this article participated in CSDN Blog Contest , please support me, vote for me.
QT Mobile Application Development (V): Scene switching