mirror of https://github.com/axmolengine/axmol.git
Merge branch 'v3' into 5176
Conflicts: build/cocos2d_libs.xcodeproj/project.pbxproj cocos/ui/UIPageView.cpp cocos/ui/UIScrollView.cpp cocos/ui/UIScrollView.h
This commit is contained in:
commit
40f2128acd
10
CHANGELOG
10
CHANGELOG
|
@ -1,10 +1,18 @@
|
|||
cocos2d-x-3.1 ???
|
||||
cocos2d-x-3.2 ???
|
||||
[NEW] TextureCache: added unbindImageAsync() and unbindAllImageAsync()
|
||||
|
||||
[FIX] Image: Set jpeg save quality to 90
|
||||
|
||||
cocos2d-x-3.1 May.24 2014
|
||||
[FIX] EventKeyboard::KeyCode: key code for back button changed from KEY_BACKSPACE to KEY_ESCAPE
|
||||
[FIX] Label: may crash when using outline effect
|
||||
[FIX] Label: using outline and invoking 'Director::setContentScaleFactor' cause label show nothing
|
||||
[FIX] ProgressTo: will start from 0 when it reaches 100
|
||||
[FIX] Physics integration: may crashes if remove bodies at physics contact callback
|
||||
[FIX] UIWidget: copyProperties() lost copy some properties
|
||||
[FIX] WP8: orientation is not correct when it is set to portrait
|
||||
[FIX] WP8: fix for precompiled shaders and precompiled headers
|
||||
[FIX] WP8: template supports orientation
|
||||
|
||||
cocos2d-x-3.1-rc0 May.18 2014
|
||||
[NEW] Cocos2dxActivity: Adds a virtual method to load native libraries.
|
||||
|
|
|
@ -944,8 +944,6 @@
|
|||
2905FA6F18CF08D100240AA3 /* UIRichText.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905FA0418CF08D000240AA3 /* UIRichText.cpp */; };
|
||||
2905FA7018CF08D100240AA3 /* UIRichText.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA0518CF08D000240AA3 /* UIRichText.h */; };
|
||||
2905FA7118CF08D100240AA3 /* UIRichText.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA0518CF08D000240AA3 /* UIRichText.h */; };
|
||||
2905FA7218CF08D100240AA3 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA0618CF08D000240AA3 /* UIScrollInterface.h */; };
|
||||
2905FA7318CF08D100240AA3 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA0618CF08D000240AA3 /* UIScrollInterface.h */; };
|
||||
2905FA7418CF08D100240AA3 /* UIScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905FA0718CF08D000240AA3 /* UIScrollView.cpp */; };
|
||||
2905FA7518CF08D100240AA3 /* UIScrollView.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2905FA0718CF08D000240AA3 /* UIScrollView.cpp */; };
|
||||
2905FA7618CF08D100240AA3 /* UIScrollView.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA0818CF08D000240AA3 /* UIScrollView.h */; };
|
||||
|
@ -975,10 +973,16 @@
|
|||
2905FA8E18CF08D100240AA3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA1418CF08D100240AA3 /* UIWidget.h */; };
|
||||
2905FA8F18CF08D100240AA3 /* UIWidget.h in Headers */ = {isa = PBXBuildFile; fileRef = 2905FA1418CF08D100240AA3 /* UIWidget.h */; };
|
||||
2986667F18B1B246000E39CA /* CCTweenFunction.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2986667818B1B079000E39CA /* CCTweenFunction.cpp */; };
|
||||
29CB8F6E192B4C8F00C841D6 /* UIFocusManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F6C192B4C8F00C841D6 /* UIFocusManager.cpp */; };
|
||||
29CB8F6F192B4C8F00C841D6 /* UIFocusManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F6C192B4C8F00C841D6 /* UIFocusManager.cpp */; };
|
||||
29CB8F70192B4C8F00C841D6 /* UIFocusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F6D192B4C8F00C841D6 /* UIFocusManager.h */; };
|
||||
29CB8F71192B4C8F00C841D6 /* UIFocusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F6D192B4C8F00C841D6 /* UIFocusManager.h */; };
|
||||
29AD4D2019330D5000C0469E /* UIFocusManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29AD4D1E19330D5000C0469E /* UIFocusManager.cpp */; };
|
||||
29AD4D2119330D5000C0469E /* UIFocusManager.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29AD4D1E19330D5000C0469E /* UIFocusManager.cpp */; };
|
||||
29AD4D2219330D5000C0469E /* UIFocusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29AD4D1F19330D5000C0469E /* UIFocusManager.h */; };
|
||||
29AD4D2319330D5000C0469E /* UIFocusManager.h in Headers */ = {isa = PBXBuildFile; fileRef = 29AD4D1F19330D5000C0469E /* UIFocusManager.h */; };
|
||||
29CB8F4C1929D1BB00C841D6 /* UILayoutExecutant.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutExecutant.cpp */; };
|
||||
29CB8F4D1929D1BB00C841D6 /* UILayoutExecutant.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 29CB8F4A1929D1BB00C841D6 /* UILayoutExecutant.cpp */; };
|
||||
29CB8F4E1929D1BB00C841D6 /* UILayoutExecutant.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutExecutant.h */; };
|
||||
29CB8F4F1929D1BB00C841D6 /* UILayoutExecutant.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F4B1929D1BB00C841D6 /* UILayoutExecutant.h */; };
|
||||
29CB8F551929D7A900C841D6 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */; };
|
||||
29CB8F561929D7A900C841D6 /* UIScrollInterface.h in Headers */ = {isa = PBXBuildFile; fileRef = 29CB8F541929D7A900C841D6 /* UIScrollInterface.h */; };
|
||||
2AC795DB1862870F005EC8E1 /* SkeletonBounds.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D918628689005EC8E1 /* SkeletonBounds.cpp */; };
|
||||
2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D51862867D005EC8E1 /* Event.cpp */; };
|
||||
2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */ = {isa = PBXBuildFile; fileRef = 2AC795D71862867D005EC8E1 /* EventData.cpp */; };
|
||||
|
@ -2239,7 +2243,6 @@
|
|||
2905FA0318CF08D000240AA3 /* UIPageView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIPageView.h; sourceTree = "<group>"; };
|
||||
2905FA0418CF08D000240AA3 /* UIRichText.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIRichText.cpp; sourceTree = "<group>"; };
|
||||
2905FA0518CF08D000240AA3 /* UIRichText.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIRichText.h; sourceTree = "<group>"; };
|
||||
2905FA0618CF08D000240AA3 /* UIScrollInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollInterface.h; sourceTree = "<group>"; };
|
||||
2905FA0718CF08D000240AA3 /* UIScrollView.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIScrollView.cpp; sourceTree = "<group>"; };
|
||||
2905FA0818CF08D000240AA3 /* UIScrollView.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollView.h; sourceTree = "<group>"; };
|
||||
2905FA0918CF08D000240AA3 /* UISlider.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UISlider.cpp; sourceTree = "<group>"; };
|
||||
|
@ -2257,8 +2260,11 @@
|
|||
29080DEB191B82CE0066F8DF /* UIDeprecated.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = UIDeprecated.h; sourceTree = "<group>"; };
|
||||
2986667818B1B079000E39CA /* CCTweenFunction.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CCTweenFunction.cpp; sourceTree = "<group>"; };
|
||||
2986667918B1B079000E39CA /* CCTweenFunction.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CCTweenFunction.h; sourceTree = "<group>"; };
|
||||
29CB8F6C192B4C8F00C841D6 /* UIFocusManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIFocusManager.cpp; sourceTree = "<group>"; };
|
||||
29CB8F6D192B4C8F00C841D6 /* UIFocusManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIFocusManager.h; sourceTree = "<group>"; };
|
||||
29AD4D1E19330D5000C0469E /* UIFocusManager.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UIFocusManager.cpp; sourceTree = "<group>"; };
|
||||
29AD4D1F19330D5000C0469E /* UIFocusManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIFocusManager.h; sourceTree = "<group>"; };
|
||||
29CB8F4A1929D1BB00C841D6 /* UILayoutExecutant.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = UILayoutExecutant.cpp; sourceTree = "<group>"; };
|
||||
29CB8F4B1929D1BB00C841D6 /* UILayoutExecutant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UILayoutExecutant.h; sourceTree = "<group>"; };
|
||||
29CB8F541929D7A900C841D6 /* UIScrollInterface.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UIScrollInterface.h; sourceTree = "<group>"; };
|
||||
2AC795D318628672005EC8E1 /* BoundingBoxAttachment.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = BoundingBoxAttachment.cpp; sourceTree = "<group>"; };
|
||||
2AC795D418628672005EC8E1 /* BoundingBoxAttachment.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = BoundingBoxAttachment.h; sourceTree = "<group>"; };
|
||||
2AC795D51862867D005EC8E1 /* Event.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = Event.cpp; sourceTree = "<group>"; };
|
||||
|
@ -3908,23 +3914,65 @@
|
|||
2905F9E618CF08D000240AA3 /* ui */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */,
|
||||
3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */,
|
||||
29CB8F531929D67D00C841D6 /* widgets */,
|
||||
29CB8F521929D65500C841D6 /* experimental */,
|
||||
29CB8F511929D64500C841D6 /* base */,
|
||||
29CB8F501929D63600C841D6 /* layout */,
|
||||
2905F9E918CF08D000240AA3 /* CocosGUI.cpp */,
|
||||
2905F9EA18CF08D000240AA3 /* CocosGUI.h */,
|
||||
2905F9EB18CF08D000240AA3 /* GUIDefine.h */,
|
||||
2905F9F018CF08D000240AA3 /* UIButton.cpp */,
|
||||
2905F9F118CF08D000240AA3 /* UIButton.h */,
|
||||
2905F9F218CF08D000240AA3 /* UICheckBox.cpp */,
|
||||
2905F9F318CF08D000240AA3 /* UICheckBox.h */,
|
||||
2905F9F418CF08D000240AA3 /* UIHelper.cpp */,
|
||||
2905F9F518CF08D000240AA3 /* UIHelper.h */,
|
||||
2905F9F618CF08D000240AA3 /* UIImageView.cpp */,
|
||||
2905F9F718CF08D000240AA3 /* UIImageView.h */,
|
||||
);
|
||||
name = ui;
|
||||
path = ../cocos/ui;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29CB8F501929D63600C841D6 /* layout */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
50E6D32E18E174130051CA34 /* UIHBox.cpp */,
|
||||
50E6D32F18E174130051CA34 /* UIHBox.h */,
|
||||
50E6D33018E174130051CA34 /* UIRelativeBox.cpp */,
|
||||
50E6D33118E174130051CA34 /* UIRelativeBox.h */,
|
||||
50E6D33218E174130051CA34 /* UIVBox.cpp */,
|
||||
50E6D33318E174130051CA34 /* UIVBox.h */,
|
||||
2905F9F818CF08D000240AA3 /* UILayout.cpp */,
|
||||
2905F9F918CF08D000240AA3 /* UILayout.h */,
|
||||
2905F9FC18CF08D000240AA3 /* UILayoutParameter.cpp */,
|
||||
2905F9FD18CF08D000240AA3 /* UILayoutParameter.h */,
|
||||
29CB8F4A1929D1BB00C841D6 /* UILayoutExecutant.cpp */,
|
||||
29CB8F4B1929D1BB00C841D6 /* UILayoutExecutant.h */,
|
||||
);
|
||||
name = layout;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29CB8F511929D64500C841D6 /* base */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
29AD4D1E19330D5000C0469E /* UIFocusManager.cpp */,
|
||||
29AD4D1F19330D5000C0469E /* UIFocusManager.h */,
|
||||
29080DEB191B82CE0066F8DF /* UIDeprecated.h */,
|
||||
2905FA1318CF08D100240AA3 /* UIWidget.cpp */,
|
||||
2905FA1418CF08D100240AA3 /* UIWidget.h */,
|
||||
50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */,
|
||||
50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */,
|
||||
2905F9F418CF08D000240AA3 /* UIHelper.cpp */,
|
||||
2905F9F518CF08D000240AA3 /* UIHelper.h */,
|
||||
2905F9EB18CF08D000240AA3 /* GUIDefine.h */,
|
||||
);
|
||||
name = base;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29CB8F521929D65500C841D6 /* experimental */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
3EA0FB69191C841D00B170C8 /* UIVideoPlayer.h */,
|
||||
3EA0FB6A191C841D00B170C8 /* UIVideoPlayerIOS.mm */,
|
||||
);
|
||||
name = experimental;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
29CB8F531929D67D00C841D6 /* widgets */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
2905F9FE18CF08D000240AA3 /* UIListView.cpp */,
|
||||
2905F9FF18CF08D000240AA3 /* UIListView.h */,
|
||||
2905FA0018CF08D000240AA3 /* UILoadingBar.cpp */,
|
||||
|
@ -3933,9 +3981,9 @@
|
|||
2905FA0318CF08D000240AA3 /* UIPageView.h */,
|
||||
2905FA0418CF08D000240AA3 /* UIRichText.cpp */,
|
||||
2905FA0518CF08D000240AA3 /* UIRichText.h */,
|
||||
2905FA0618CF08D000240AA3 /* UIScrollInterface.h */,
|
||||
2905FA0718CF08D000240AA3 /* UIScrollView.cpp */,
|
||||
2905FA0818CF08D000240AA3 /* UIScrollView.h */,
|
||||
29CB8F541929D7A900C841D6 /* UIScrollInterface.h */,
|
||||
2905FA0918CF08D000240AA3 /* UISlider.cpp */,
|
||||
2905FA0A18CF08D100240AA3 /* UISlider.h */,
|
||||
2905FA0B18CF08D100240AA3 /* UIText.cpp */,
|
||||
|
@ -3946,22 +3994,14 @@
|
|||
2905FA1018CF08D100240AA3 /* UITextBMFont.h */,
|
||||
2905FA1118CF08D100240AA3 /* UITextField.cpp */,
|
||||
2905FA1218CF08D100240AA3 /* UITextField.h */,
|
||||
2905FA1318CF08D100240AA3 /* UIWidget.cpp */,
|
||||
2905FA1418CF08D100240AA3 /* UIWidget.h */,
|
||||
50E6D30C18DADB5D0051CA34 /* CCProtectedNode.cpp */,
|
||||
50E6D30D18DADB5D0051CA34 /* CCProtectedNode.h */,
|
||||
50E6D32E18E174130051CA34 /* UIHBox.cpp */,
|
||||
50E6D32F18E174130051CA34 /* UIHBox.h */,
|
||||
50E6D33018E174130051CA34 /* UIRelativeBox.cpp */,
|
||||
50E6D33118E174130051CA34 /* UIRelativeBox.h */,
|
||||
50E6D33218E174130051CA34 /* UIVBox.cpp */,
|
||||
50E6D33318E174130051CA34 /* UIVBox.h */,
|
||||
29080DEB191B82CE0066F8DF /* UIDeprecated.h */,
|
||||
29CB8F6C192B4C8F00C841D6 /* UIFocusManager.cpp */,
|
||||
29CB8F6D192B4C8F00C841D6 /* UIFocusManager.h */,
|
||||
2905F9F018CF08D000240AA3 /* UIButton.cpp */,
|
||||
2905F9F118CF08D000240AA3 /* UIButton.h */,
|
||||
2905F9F218CF08D000240AA3 /* UICheckBox.cpp */,
|
||||
2905F9F318CF08D000240AA3 /* UICheckBox.h */,
|
||||
2905F9F618CF08D000240AA3 /* UIImageView.cpp */,
|
||||
2905F9F718CF08D000240AA3 /* UIImageView.h */,
|
||||
);
|
||||
name = ui;
|
||||
path = ../cocos/ui;
|
||||
name = widgets;
|
||||
sourceTree = "<group>";
|
||||
};
|
||||
37936A361869B76800E974DD /* internal */ = {
|
||||
|
@ -4814,6 +4854,7 @@
|
|||
5034CA39191D591100CE6051 /* ccShader_PositionColorLengthTexture.frag in Headers */,
|
||||
2AC795DF18628723005EC8E1 /* SkeletonBounds.h in Headers */,
|
||||
50ABBE891925AB6F00A911A9 /* CCMap.h in Headers */,
|
||||
29CB8F4E1929D1BB00C841D6 /* UILayoutExecutant.h in Headers */,
|
||||
2AC795E018628723005EC8E1 /* Event.h in Headers */,
|
||||
2AC795E118628723005EC8E1 /* EventData.h in Headers */,
|
||||
50E6D33618E174130051CA34 /* UIHBox.h in Headers */,
|
||||
|
@ -5003,6 +5044,7 @@
|
|||
50ABBE9D1925AB6F00A911A9 /* CCRefPtr.h in Headers */,
|
||||
1AD71DBF180E26E600808F54 /* CCBSequence.h in Headers */,
|
||||
1AD71DC3180E26E600808F54 /* CCBSequenceProperty.h in Headers */,
|
||||
29AD4D2219330D5000C0469E /* UIFocusManager.h in Headers */,
|
||||
5034CA31191D591100CE6051 /* ccShader_PositionTexture_uColor.vert in Headers */,
|
||||
1AD71DCB180E26E600808F54 /* CCControlButtonLoader.h in Headers */,
|
||||
1AD71DCF180E26E600808F54 /* CCControlLoader.h in Headers */,
|
||||
|
@ -5018,7 +5060,6 @@
|
|||
1AD71DED180E26E600808F54 /* CCMenuLoader.h in Headers */,
|
||||
50ABBE8F1925AB6F00A911A9 /* CCPlatformConfig.h in Headers */,
|
||||
1AD71DF1180E26E600808F54 /* CCNode+CCBRelativePositioning.h in Headers */,
|
||||
2905FA7218CF08D100240AA3 /* UIScrollInterface.h in Headers */,
|
||||
1AD71DF5180E26E600808F54 /* CCNodeLoader.h in Headers */,
|
||||
1AD71DF9180E26E600808F54 /* CCNodeLoaderLibrary.h in Headers */,
|
||||
50ABBE291925AB6F00A911A9 /* CCAutoreleasePool.h in Headers */,
|
||||
|
@ -5077,13 +5118,13 @@
|
|||
50ABBE3F1925AB6F00A911A9 /* CCDataVisitor.h in Headers */,
|
||||
1AD71EDF180E26E600808F54 /* Slot.h in Headers */,
|
||||
1AD71EE3180E26E600808F54 /* SlotData.h in Headers */,
|
||||
29CB8F70192B4C8F00C841D6 /* UIFocusManager.h in Headers */,
|
||||
1AD71EE7180E26E600808F54 /* spine-cocos2dx.h in Headers */,
|
||||
1AD71EE9180E26E600808F54 /* spine.h in Headers */,
|
||||
1AAF536C180E3374000584C8 /* HttpClient.h in Headers */,
|
||||
50ABBD9D1925AB4100A911A9 /* ccGLStateCache.h in Headers */,
|
||||
50ABBEB91925AB6F00A911A9 /* ccUTF8.h in Headers */,
|
||||
1AAF536E180E3374000584C8 /* HttpRequest.h in Headers */,
|
||||
29CB8F551929D7A900C841D6 /* UIScrollInterface.h in Headers */,
|
||||
1AAF5370180E3374000584C8 /* HttpResponse.h in Headers */,
|
||||
50ABBE671925AB6F00A911A9 /* CCEventListenerCustom.h in Headers */,
|
||||
1AAF5374180E3374000584C8 /* SocketIO.h in Headers */,
|
||||
|
@ -5366,7 +5407,6 @@
|
|||
503DD8E41926736A00CD74DD /* CCDirectorCaller.h in Headers */,
|
||||
50ABBD8A1925AB4100A911A9 /* CCCustomCommand.h in Headers */,
|
||||
2905FA6D18CF08D100240AA3 /* UIPageView.h in Headers */,
|
||||
2905FA7318CF08D100240AA3 /* UIScrollInterface.h in Headers */,
|
||||
50ABBE881925AB6F00A911A9 /* ccMacros.h in Headers */,
|
||||
50ABC0101926664800A911A9 /* CCFileUtils.h in Headers */,
|
||||
2905FA4318CF08D100240AA3 /* CocosGUI.h in Headers */,
|
||||
|
@ -5513,6 +5553,7 @@
|
|||
1AD71DDC180E26E600808F54 /* CCLayerColorLoader.h in Headers */,
|
||||
1AD71DE0180E26E600808F54 /* CCLayerGradientLoader.h in Headers */,
|
||||
1AD71DE4180E26E600808F54 /* CCLayerLoader.h in Headers */,
|
||||
29AD4D2319330D5000C0469E /* UIFocusManager.h in Headers */,
|
||||
50ABBEC81925AB6F00A911A9 /* etc1.h in Headers */,
|
||||
1AD71DE8180E26E600808F54 /* CCMenuItemImageLoader.h in Headers */,
|
||||
50E6D31118DAF01E0051CA34 /* CCProtectedNode.h in Headers */,
|
||||
|
@ -5537,6 +5578,7 @@
|
|||
50ABBD921925AB4100A911A9 /* CCGLProgramCache.h in Headers */,
|
||||
1AD71E0E180E26E600808F54 /* CocosBuilder.h in Headers */,
|
||||
B29594C91926D61F003EEF37 /* CCObjLoader.h in Headers */,
|
||||
29CB8F561929D7A900C841D6 /* UIScrollInterface.h in Headers */,
|
||||
1AD71E98180E26E600808F54 /* Animation.h in Headers */,
|
||||
1AD71E9C180E26E600808F54 /* AnimationState.h in Headers */,
|
||||
50ABBE961925AB6F00A911A9 /* CCProfiling.h in Headers */,
|
||||
|
@ -5609,7 +5651,6 @@
|
|||
50ABBE261925AB6F00A911A9 /* base64.h in Headers */,
|
||||
1A8C59C2180E930E00EF57C3 /* CCComAudio.h in Headers */,
|
||||
1A01C68718F57BE800EFE3A6 /* CCArray.h in Headers */,
|
||||
29CB8F71192B4C8F00C841D6 /* UIFocusManager.h in Headers */,
|
||||
1A01C6A718F58F7500EFE3A6 /* CCNotificationCenter.h in Headers */,
|
||||
1A8C59C6180E930E00EF57C3 /* CCComController.h in Headers */,
|
||||
50ABBEDA1925AB6F00A911A9 /* ZipUtils.h in Headers */,
|
||||
|
@ -5630,6 +5671,7 @@
|
|||
1A8C59E2180E930E00EF57C3 /* CCInputDelegate.h in Headers */,
|
||||
503DD8EA1926736A00CD74DD /* CCESRenderer.h in Headers */,
|
||||
1A8C59E6180E930E00EF57C3 /* CCProcessBase.h in Headers */,
|
||||
29CB8F4F1929D1BB00C841D6 /* UILayoutExecutant.h in Headers */,
|
||||
50ABBE581925AB6F00A911A9 /* CCEventFocus.h in Headers */,
|
||||
50ABC00A1926664800A911A9 /* CCCommon.h in Headers */,
|
||||
2905FA5918CF08D100240AA3 /* UILayout.h in Headers */,
|
||||
|
@ -6011,6 +6053,7 @@
|
|||
50ABBE2B1925AB6F00A911A9 /* ccCArray.cpp in Sources */,
|
||||
2AC795DC1862870F005EC8E1 /* Event.cpp in Sources */,
|
||||
1A01C68A18F57BE800EFE3A6 /* CCDeprecated.cpp in Sources */,
|
||||
29AD4D2019330D5000C0469E /* UIFocusManager.cpp in Sources */,
|
||||
1A1645B0191B726C008C7C7F /* ConvertUTF.c in Sources */,
|
||||
2905FA5618CF08D100240AA3 /* UILayout.cpp in Sources */,
|
||||
2AC795DD1862870F005EC8E1 /* EventData.cpp in Sources */,
|
||||
|
@ -6147,7 +6190,6 @@
|
|||
1A570310180BCF190088DEC7 /* CCComponentContainer.cpp in Sources */,
|
||||
B37510711823AC9F00B3BA6A /* CCPhysicsBodyInfo_chipmunk.cpp in Sources */,
|
||||
1A01C69C18F57BE800EFE3A6 /* CCString.cpp in Sources */,
|
||||
29CB8F6E192B4C8F00C841D6 /* UIFocusManager.cpp in Sources */,
|
||||
50ABBD3C1925AB0000A911A9 /* CCGeometry.cpp in Sources */,
|
||||
50ABC0011926664800A911A9 /* CCLock.cpp in Sources */,
|
||||
50E6D30E18DADB5D0051CA34 /* CCProtectedNode.cpp in Sources */,
|
||||
|
@ -6211,6 +6253,7 @@
|
|||
2905FA4018CF08D100240AA3 /* CocosGUI.cpp in Sources */,
|
||||
1AD71EC1180E26E600808F54 /* extension.cpp in Sources */,
|
||||
50ABBE511925AB6F00A911A9 /* CCEventDispatcher.cpp in Sources */,
|
||||
29CB8F4C1929D1BB00C841D6 /* UILayoutExecutant.cpp in Sources */,
|
||||
50ABC0051926664800A911A9 /* CCThread.mm in Sources */,
|
||||
1AD71EC5180E26E600808F54 /* Json.cpp in Sources */,
|
||||
50E6D33C18E174130051CA34 /* UIVBox.cpp in Sources */,
|
||||
|
@ -6508,7 +6551,6 @@
|
|||
50ABBD4D1925AB0000A911A9 /* MathUtil.cpp in Sources */,
|
||||
50ABBE3E1925AB6F00A911A9 /* CCDataVisitor.cpp in Sources */,
|
||||
1A57009F180BC5D20088DEC7 /* CCNode.cpp in Sources */,
|
||||
29CB8F6F192B4C8F00C841D6 /* UIFocusManager.cpp in Sources */,
|
||||
B37510831823ACA100B3BA6A /* CCPhysicsShapeInfo_chipmunk.cpp in Sources */,
|
||||
B29594CF1926D61F003EEF37 /* CCSprite3DDataCache.cpp in Sources */,
|
||||
1A57010F180BC8EE0088DEC7 /* CCDrawingPrimitives.cpp in Sources */,
|
||||
|
@ -6600,6 +6642,7 @@
|
|||
1AD71DAA180E26E600808F54 /* CCBAnimationManager.cpp in Sources */,
|
||||
50ABBD881925AB4100A911A9 /* CCCustomCommand.cpp in Sources */,
|
||||
50ABBE941925AB6F00A911A9 /* CCProfiling.cpp in Sources */,
|
||||
29AD4D2119330D5000C0469E /* UIFocusManager.cpp in Sources */,
|
||||
1AD71DAE180E26E600808F54 /* CCBFileLoader.cpp in Sources */,
|
||||
1AD71DB2180E26E600808F54 /* CCBKeyframe.cpp in Sources */,
|
||||
1AD71DB8180E26E600808F54 /* CCBReader.cpp in Sources */,
|
||||
|
@ -6690,6 +6733,7 @@
|
|||
50FCEBAC18C72017004AD434 /* PageViewReader.cpp in Sources */,
|
||||
1A8C598C180E930E00EF57C3 /* CCActionFrame.cpp in Sources */,
|
||||
1A8C5990180E930E00EF57C3 /* CCActionFrameEasing.cpp in Sources */,
|
||||
29CB8F4D1929D1BB00C841D6 /* UILayoutExecutant.cpp in Sources */,
|
||||
50FCEBA418C72017004AD434 /* ListViewReader.cpp in Sources */,
|
||||
1A8C5994180E930E00EF57C3 /* CCActionManagerEx.cpp in Sources */,
|
||||
50ABBEBC1925AB6F00A911A9 /* ccUtils.cpp in Sources */,
|
||||
|
|
|
@ -85,6 +85,8 @@
|
|||
15C90B4A18E66C2B00D69802 /* tp.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB118DA8B6C00F6518C /* tp.lua */; };
|
||||
15C90B4B18E66C2F00D69802 /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; };
|
||||
15C90B4C18E66C3100D69802 /* url.lua in Resources */ = {isa = PBXBuildFile; fileRef = 1503FAB218DA8B6C00F6518C /* url.lua */; };
|
||||
15E66FC8192D957100C20A52 /* Sprite3DTest in Resources */ = {isa = PBXBuildFile; fileRef = 3E92EA841921A7720094CD21 /* Sprite3DTest */; };
|
||||
15E66FD6192DC8C700C20A52 /* Sprite3DTest in Resources */ = {isa = PBXBuildFile; fileRef = 3E92EA841921A7720094CD21 /* Sprite3DTest */; };
|
||||
1A0EE2A118CDF6DA004CD58F /* libchipmunk Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB41807A4F9005B8026 /* libchipmunk Mac.a */; };
|
||||
1A0EE2A218CDF6DA004CD58F /* libcocos2dx Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB01807A4F9005B8026 /* libcocos2dx Mac.a */; };
|
||||
1A0EE2A418CDF6DA004CD58F /* libCocosDenshion Mac.a in Frameworks */ = {isa = PBXBuildFile; fileRef = 46A15FB81807A4F9005B8026 /* libCocosDenshion Mac.a */; };
|
||||
|
@ -4020,11 +4022,6 @@
|
|||
isa = PBXProject;
|
||||
attributes = {
|
||||
LastUpgradeCheck = 0510;
|
||||
TargetAttributes = {
|
||||
1ABCA2CC18CD93580087CE3A = {
|
||||
DevelopmentTeam = NQ596S94Q5;
|
||||
};
|
||||
};
|
||||
};
|
||||
buildConfigurationList = C01FCF4E08A954540054247B /* Build configuration list for PBXProject "cocos2d_tests" */;
|
||||
compatibilityVersion = "Xcode 3.2";
|
||||
|
@ -4286,6 +4283,7 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
15E66FD6192DC8C700C20A52 /* Sprite3DTest in Resources */,
|
||||
1AC35DC318CEE65100F37B72 /* Misc in Resources */,
|
||||
1AC35DC618CEE65100F37B72 /* Shaders in Resources */,
|
||||
1AC35DBB18CEE65100F37B72 /* components in Resources */,
|
||||
|
@ -4354,6 +4352,7 @@
|
|||
isa = PBXResourcesBuildPhase;
|
||||
buildActionMask = 2147483647;
|
||||
files = (
|
||||
15E66FC8192D957100C20A52 /* Sprite3DTest in Resources */,
|
||||
15C90B4418E66C1800D69802 /* mime.lua in Resources */,
|
||||
15C90B4C18E66C3100D69802 /* url.lua in Resources */,
|
||||
1AC35DD618CEE65200F37B72 /* Misc in Resources */,
|
||||
|
@ -5423,14 +5422,12 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/../tests/lua-tests/project/proj.ios_mac/ios/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
PROVISIONING_PROFILE = "";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
|
@ -5441,14 +5438,12 @@
|
|||
isa = XCBuildConfiguration;
|
||||
buildSettings = {
|
||||
CODE_SIGN_IDENTITY = "iPhone Developer";
|
||||
"CODE_SIGN_IDENTITY[sdk=iphoneos*]" = "iPhone Developer";
|
||||
GCC_PREPROCESSOR_DEFINITIONS = (
|
||||
"$(inherited)",
|
||||
CC_TARGET_OS_IPHONE,
|
||||
);
|
||||
INFOPLIST_FILE = "$(SRCROOT)/../tests/lua-tests/project/proj.ios_mac/ios/Info.plist";
|
||||
IPHONEOS_DEPLOYMENT_TARGET = 5.1.1;
|
||||
PROVISIONING_PROFILE = "";
|
||||
SDKROOT = iphoneos;
|
||||
TARGETED_DEVICE_FAMILY = "1,2";
|
||||
USER_HEADER_SEARCH_PATHS = "$(inherited) $(SRCROOT)/.. $(SRCROOT)/../cocos/platform/ios $(SRCROOT)/../external $(SRCROOT)/../external/lua/luajit/include $(SRCROOT)/../external/lua/tolua $(SRCROOT)/../cocos/scripting/lua-bindings/manual $(SRCROOT)/../cocos/scripting/lua-bindings/auto";
|
||||
|
|
|
@ -296,18 +296,18 @@ unsigned char* FontFreeType::getGlyphBitmap(unsigned short theChar, long &outWid
|
|||
break;
|
||||
}
|
||||
|
||||
long outlineWidth = (bbox.xMax - bbox.xMin)>>6;
|
||||
long outlineHeight = (bbox.yMax - bbox.yMin)>>6;
|
||||
auto outlineWidth = (bbox.xMax - bbox.xMin)>>6;
|
||||
auto outlineHeight = (bbox.yMax - bbox.yMin)>>6;
|
||||
|
||||
long blendWidth = outlineWidth > outWidth ? outlineWidth : outWidth;
|
||||
long blendHeight = outlineHeight > outHeight ? outlineHeight : outHeight;
|
||||
auto blendWidth = outlineWidth > outWidth ? outlineWidth : outWidth;
|
||||
auto blendHeight = outlineHeight > outHeight ? outlineHeight : outHeight;
|
||||
|
||||
long index,index2;
|
||||
auto blendImage = new unsigned char[blendWidth * blendHeight * 2];
|
||||
memset(blendImage, 0, blendWidth * blendHeight * 2);
|
||||
|
||||
int px = (blendWidth - outlineWidth) / 2;
|
||||
int py = (blendHeight - outlineHeight) / 2;
|
||||
auto px = (blendWidth - outlineWidth) / 2;
|
||||
auto py = (blendHeight - outlineHeight) / 2;
|
||||
for (int x = 0; x < outlineWidth; ++x)
|
||||
{
|
||||
for (int y = 0; y < outlineHeight; ++y)
|
||||
|
|
|
@ -31,7 +31,7 @@ NS_CC_BEGIN
|
|||
|
||||
const char* cocos2dVersion()
|
||||
{
|
||||
return "cocos2d-x 3.1rc0";
|
||||
return "cocos2d-x 3.1";
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
|
|
|
@ -2120,7 +2120,8 @@ bool Image::saveImageToJPG(const std::string& filePath)
|
|||
cinfo.in_color_space = JCS_RGB; /* colorspace of input image */
|
||||
|
||||
jpeg_set_defaults(&cinfo);
|
||||
|
||||
jpeg_set_quality(&cinfo, 90, TRUE);
|
||||
|
||||
jpeg_start_compress(&cinfo, TRUE);
|
||||
|
||||
row_stride = _width * 3; /* JSAMPLEs per row in image_buffer */
|
||||
|
|
|
@ -141,6 +141,31 @@ void TextureCache::addImageAsync(const std::string &path, const std::function<vo
|
|||
_sleepCondition.notify_one();
|
||||
}
|
||||
|
||||
void TextureCache::unbindImageAsync(const std::string& filename)
|
||||
{
|
||||
_imageInfoMutex.lock();
|
||||
if (_imageInfoQueue && !_imageInfoQueue->empty())
|
||||
{
|
||||
std::string fullpath = FileUtils::getInstance()->fullPathForFilename(filename);
|
||||
auto found = std::find_if(_imageInfoQueue->begin(), _imageInfoQueue->end(), [&fullpath](ImageInfo* ptr)->bool{ return ptr->asyncStruct->filename == fullpath; });
|
||||
if (found != _imageInfoQueue->end())
|
||||
{
|
||||
(*found)->asyncStruct->callback = nullptr;
|
||||
}
|
||||
}
|
||||
_imageInfoMutex.unlock();
|
||||
}
|
||||
|
||||
void TextureCache::unbindAllImageAsync()
|
||||
{
|
||||
_imageInfoMutex.lock();
|
||||
if (_imageInfoQueue && !_imageInfoQueue->empty())
|
||||
{
|
||||
std::for_each(_imageInfoQueue->begin(), _imageInfoQueue->end(), [](ImageInfo* ptr) { ptr->asyncStruct->callback = nullptr; });
|
||||
}
|
||||
_imageInfoMutex.unlock();
|
||||
}
|
||||
|
||||
void TextureCache::loadImage()
|
||||
{
|
||||
AsyncStruct *asyncStruct = nullptr;
|
||||
|
@ -268,7 +293,11 @@ void TextureCache::addImageAsyncCallBack(float dt)
|
|||
texture = it->second;
|
||||
}
|
||||
|
||||
asyncStruct->callback(texture);
|
||||
if (asyncStruct->callback)
|
||||
{
|
||||
asyncStruct->callback(texture);
|
||||
}
|
||||
|
||||
if(image)
|
||||
{
|
||||
image->release();
|
||||
|
|
|
@ -118,6 +118,18 @@ public:
|
|||
* @since v0.8
|
||||
*/
|
||||
virtual void addImageAsync(const std::string &filepath, const std::function<void(Texture2D*)>& callback);
|
||||
|
||||
/* Unbind a specified bound image asynchronous callback
|
||||
* In the case an object who was bound to an image asynchronous callback was destroyed before the callback is invoked,
|
||||
* the object always need to unbind this callback manually.
|
||||
* @since v3.1
|
||||
*/
|
||||
virtual void unbindImageAsync(const std::string &filename);
|
||||
|
||||
/* Unbind all bound image asynchronous load callbacks
|
||||
* @since v3.1
|
||||
*/
|
||||
virtual void unbindAllImageAsync();
|
||||
|
||||
/** Returns a Texture2D object given an Image.
|
||||
* If the image was not previously loaded, it will create a new Texture2D object and it will return it.
|
||||
|
|
|
@ -43,4 +43,11 @@
|
|||
-- @param #cc.Node node
|
||||
-- @return ClippingNode#ClippingNode ret (retunr value: cc.ClippingNode)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ClippingNode] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
return nil
|
||||
|
|
|
@ -41,6 +41,11 @@
|
|||
-- @param #string str
|
||||
-- @return array_table#array_table ret (return value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] getSearchPaths
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (return value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] writeToFile
|
||||
-- @param self
|
||||
|
@ -54,6 +59,16 @@
|
|||
-- @param #string str
|
||||
-- @return map_table#map_table ret (return value: map_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] setSearchPaths
|
||||
-- @param self
|
||||
-- @param #array_table array
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] setSearchResolutionsOrder
|
||||
-- @param self
|
||||
-- @param #array_table array
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] addSearchResolutionsOrder
|
||||
-- @param self
|
||||
|
@ -86,6 +101,11 @@
|
|||
-- @param self
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] getSearchResolutionsOrder
|
||||
-- @param self
|
||||
-- @return array_table#array_table ret (return value: array_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#FileUtils] getWritablePath
|
||||
-- @param self
|
||||
|
|
|
@ -301,6 +301,13 @@
|
|||
-- @param self
|
||||
-- @param #cc.BlendFunc blendfunc
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Label] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Label] getScaleX
|
||||
-- @param self
|
||||
|
|
|
@ -177,6 +177,13 @@
|
|||
-- @param self
|
||||
-- @return size_table#size_table ret (return value: size_table)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#LabelTTF] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#LabelTTF] LabelTTF
|
||||
-- @param self
|
||||
|
|
|
@ -315,6 +315,17 @@
|
|||
-- @param #cc.Component component
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- overload function: visit()
|
||||
--
|
||||
-- overload function: visit(cc.Renderer, cc.Mat4, bool)
|
||||
--
|
||||
-- @function [parent=#Node] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#Node] isOpacityModifyRGB
|
||||
-- @param self
|
||||
|
|
|
@ -27,4 +27,11 @@
|
|||
-- @param self
|
||||
-- @return NodeGrid#NodeGrid ret (return value: cc.NodeGrid)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#NodeGrid] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
return nil
|
||||
|
|
|
@ -33,6 +33,13 @@
|
|||
-- @param #int int
|
||||
-- @param #int int
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ParallaxNode] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ParallaxNode] removeChild
|
||||
-- @param self
|
||||
|
|
|
@ -73,6 +73,13 @@
|
|||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ParticleBatchNode] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ParticleBatchNode] reorderChild
|
||||
-- @param self
|
||||
|
|
|
@ -62,6 +62,13 @@
|
|||
-- @param self
|
||||
-- @return ProtectedNode#ProtectedNode ret (return value: cc.ProtectedNode)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ProtectedNode] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#ProtectedNode] updateDisplayedOpacity
|
||||
-- @param self
|
||||
|
|
|
@ -172,6 +172,13 @@
|
|||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RenderTexture] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#RenderTexture] RenderTexture
|
||||
-- @param self
|
||||
|
|
|
@ -126,6 +126,13 @@
|
|||
-- @param self
|
||||
-- @return string#string ret (return value: string)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#SpriteBatchNode] visit
|
||||
-- @param self
|
||||
-- @param #cc.Renderer renderer
|
||||
-- @param #cc.Mat4 mat4
|
||||
-- @param #bool bool
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#SpriteBatchNode] sortAllChildren
|
||||
-- @param self
|
||||
|
|
|
@ -9,6 +9,10 @@
|
|||
-- @param #string str
|
||||
-- @return bool#bool ret (return value: bool)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextureCache] unbindAllImageAsync
|
||||
-- @param self
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextureCache] removeTextureForKey
|
||||
-- @param self
|
||||
|
@ -39,6 +43,11 @@
|
|||
-- @param #string str
|
||||
-- @return Texture2D#Texture2D ret (retunr value: cc.Texture2D)
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextureCache] unbindImageAsync
|
||||
-- @param self
|
||||
-- @param #string str
|
||||
|
||||
--------------------------------
|
||||
-- @function [parent=#TextureCache] getTextureForKey
|
||||
-- @param self
|
||||
|
|
|
@ -6330,6 +6330,63 @@ int lua_cocos2dx_Node_addComponent(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Node_visit(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::Node* cobj = nullptr;
|
||||
bool ok = true;
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.Node",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
cobj = (cocos2d::Node*)tolua_tousertype(tolua_S,1,0);
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_Node_visit'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
do{
|
||||
if (argc == 0) {
|
||||
cobj->visit();
|
||||
return 0;
|
||||
}
|
||||
}while(0);
|
||||
ok = true;
|
||||
do{
|
||||
if (argc == 3) {
|
||||
cocos2d::Renderer* arg0;
|
||||
ok &= luaval_to_object<cocos2d::Renderer>(tolua_S, 2, "cc.Renderer",&arg0);
|
||||
|
||||
if (!ok) { break; }
|
||||
cocos2d::Mat4 arg1;
|
||||
ok &= luaval_to_mat4(tolua_S, 3, &arg1);
|
||||
|
||||
if (!ok) { break; }
|
||||
bool arg2;
|
||||
ok &= luaval_to_boolean(tolua_S, 4,&arg2);
|
||||
|
||||
if (!ok) { break; }
|
||||
cobj->visit(arg0, arg1, arg2);
|
||||
return 0;
|
||||
}
|
||||
}while(0);
|
||||
ok = true;
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "visit",argc, 3);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_Node_visit'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_Node_isOpacityModifyRGB(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -9311,6 +9368,7 @@ int lua_register_cocos2dx_Node(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"getChildrenCount",lua_cocos2dx_Node_getChildrenCount);
|
||||
tolua_function(tolua_S,"convertToNodeSpaceAR",lua_cocos2dx_Node_convertToNodeSpaceAR);
|
||||
tolua_function(tolua_S,"addComponent",lua_cocos2dx_Node_addComponent);
|
||||
tolua_function(tolua_S,"visit",lua_cocos2dx_Node_visit);
|
||||
tolua_function(tolua_S,"isOpacityModifyRGB",lua_cocos2dx_Node_isOpacityModifyRGB);
|
||||
tolua_function(tolua_S,"getRotation",lua_cocos2dx_Node_getRotation);
|
||||
tolua_function(tolua_S,"getAnchorPointInPoints",lua_cocos2dx_Node_getAnchorPointInPoints);
|
||||
|
@ -14412,6 +14470,50 @@ int lua_cocos2dx_FileUtils_getValueVectorFromFile(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_getSearchPaths(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FileUtils* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getSearchPaths'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
const std::vector<std::string>& ret = cobj->getSearchPaths();
|
||||
ccvector_std_string_to_luaval(tolua_S, ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSearchPaths",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getSearchPaths'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_writeToFile(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -14509,6 +14611,98 @@ int lua_cocos2dx_FileUtils_getValueMapFromFile(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_setSearchPaths(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FileUtils* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_setSearchPaths'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
std::vector<std::string> arg0;
|
||||
|
||||
ok &= luaval_to_std_vector_string(tolua_S, 2, &arg0);
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->setSearchPaths(arg0);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSearchPaths",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_setSearchPaths'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_setSearchResolutionsOrder(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FileUtils* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_setSearchResolutionsOrder'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
std::vector<std::string> arg0;
|
||||
|
||||
ok &= luaval_to_std_vector_string(tolua_S, 2, &arg0);
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->setSearchResolutionsOrder(arg0);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setSearchResolutionsOrder",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_setSearchResolutionsOrder'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_addSearchResolutionsOrder(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -14787,6 +14981,50 @@ int lua_cocos2dx_FileUtils_setPopupNotify(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_getSearchResolutionsOrder(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::FileUtils* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.FileUtils",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::FileUtils*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_FileUtils_getSearchResolutionsOrder'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
const std::vector<std::string>& ret = cobj->getSearchResolutionsOrder();
|
||||
ccvector_std_string_to_luaval(tolua_S, ret);
|
||||
return 1;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "getSearchResolutionsOrder",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_FileUtils_getSearchResolutionsOrder'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_FileUtils_getWritablePath(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -14911,14 +15149,18 @@ int lua_register_cocos2dx_FileUtils(lua_State* tolua_S)
|
|||
tolua_function(tolua_S,"loadFilenameLookup",lua_cocos2dx_FileUtils_loadFilenameLookupDictionaryFromFile);
|
||||
tolua_function(tolua_S,"isPopupNotify",lua_cocos2dx_FileUtils_isPopupNotify);
|
||||
tolua_function(tolua_S,"getValueVectorFromFile",lua_cocos2dx_FileUtils_getValueVectorFromFile);
|
||||
tolua_function(tolua_S,"getSearchPaths",lua_cocos2dx_FileUtils_getSearchPaths);
|
||||
tolua_function(tolua_S,"writeToFile",lua_cocos2dx_FileUtils_writeToFile);
|
||||
tolua_function(tolua_S,"getValueMapFromFile",lua_cocos2dx_FileUtils_getValueMapFromFile);
|
||||
tolua_function(tolua_S,"setSearchPaths",lua_cocos2dx_FileUtils_setSearchPaths);
|
||||
tolua_function(tolua_S,"setSearchResolutionsOrder",lua_cocos2dx_FileUtils_setSearchResolutionsOrder);
|
||||
tolua_function(tolua_S,"addSearchResolutionsOrder",lua_cocos2dx_FileUtils_addSearchResolutionsOrder);
|
||||
tolua_function(tolua_S,"addSearchPath",lua_cocos2dx_FileUtils_addSearchPath);
|
||||
tolua_function(tolua_S,"isFileExist",lua_cocos2dx_FileUtils_isFileExist);
|
||||
tolua_function(tolua_S,"purgeCachedEntries",lua_cocos2dx_FileUtils_purgeCachedEntries);
|
||||
tolua_function(tolua_S,"fullPathFromRelativeFile",lua_cocos2dx_FileUtils_fullPathFromRelativeFile);
|
||||
tolua_function(tolua_S,"setPopupNotify",lua_cocos2dx_FileUtils_setPopupNotify);
|
||||
tolua_function(tolua_S,"getSearchResolutionsOrder",lua_cocos2dx_FileUtils_getSearchResolutionsOrder);
|
||||
tolua_function(tolua_S,"getWritablePath",lua_cocos2dx_FileUtils_getWritablePath);
|
||||
tolua_function(tolua_S,"destroyInstance", lua_cocos2dx_FileUtils_destroyInstance);
|
||||
tolua_function(tolua_S,"getInstance", lua_cocos2dx_FileUtils_getInstance);
|
||||
|
@ -56520,6 +56762,49 @@ int lua_cocos2dx_TextureCache_reloadTexture(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_TextureCache_unbindAllImageAsync(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::TextureCache* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_unbindAllImageAsync'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 0)
|
||||
{
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->unbindAllImageAsync();
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unbindAllImageAsync",argc, 0);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_unbindAllImageAsync'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_TextureCache_removeTextureForKey(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -56756,6 +57041,52 @@ int lua_cocos2dx_TextureCache_addImage(lua_State* tolua_S)
|
|||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_TextureCache_unbindImageAsync(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
cocos2d::TextureCache* cobj = nullptr;
|
||||
bool ok = true;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_Error tolua_err;
|
||||
#endif
|
||||
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!tolua_isusertype(tolua_S,1,"cc.TextureCache",0,&tolua_err)) goto tolua_lerror;
|
||||
#endif
|
||||
|
||||
cobj = (cocos2d::TextureCache*)tolua_tousertype(tolua_S,1,0);
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
if (!cobj)
|
||||
{
|
||||
tolua_error(tolua_S,"invalid 'cobj' in function 'lua_cocos2dx_TextureCache_unbindImageAsync'", nullptr);
|
||||
return 0;
|
||||
}
|
||||
#endif
|
||||
|
||||
argc = lua_gettop(tolua_S)-1;
|
||||
if (argc == 1)
|
||||
{
|
||||
std::string arg0;
|
||||
|
||||
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
|
||||
if(!ok)
|
||||
return 0;
|
||||
cobj->unbindImageAsync(arg0);
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "unbindImageAsync",argc, 1);
|
||||
return 0;
|
||||
|
||||
#if COCOS2D_DEBUG >= 1
|
||||
tolua_lerror:
|
||||
tolua_error(tolua_S,"#ferror in function 'lua_cocos2dx_TextureCache_unbindImageAsync'.",&tolua_err);
|
||||
#endif
|
||||
|
||||
return 0;
|
||||
}
|
||||
int lua_cocos2dx_TextureCache_getTextureForKey(lua_State* tolua_S)
|
||||
{
|
||||
int argc = 0;
|
||||
|
@ -56982,11 +57313,13 @@ int lua_register_cocos2dx_TextureCache(lua_State* tolua_S)
|
|||
|
||||
tolua_beginmodule(tolua_S,"TextureCache");
|
||||
tolua_function(tolua_S,"reloadTexture",lua_cocos2dx_TextureCache_reloadTexture);
|
||||
tolua_function(tolua_S,"unbindAllImageAsync",lua_cocos2dx_TextureCache_unbindAllImageAsync);
|
||||
tolua_function(tolua_S,"removeTextureForKey",lua_cocos2dx_TextureCache_removeTextureForKey);
|
||||
tolua_function(tolua_S,"removeAllTextures",lua_cocos2dx_TextureCache_removeAllTextures);
|
||||
tolua_function(tolua_S,"getDescription",lua_cocos2dx_TextureCache_getDescription);
|
||||
tolua_function(tolua_S,"getCachedTextureInfo",lua_cocos2dx_TextureCache_getCachedTextureInfo);
|
||||
tolua_function(tolua_S,"addImage",lua_cocos2dx_TextureCache_addImage);
|
||||
tolua_function(tolua_S,"unbindImageAsync",lua_cocos2dx_TextureCache_unbindImageAsync);
|
||||
tolua_function(tolua_S,"getTextureForKey",lua_cocos2dx_TextureCache_getTextureForKey);
|
||||
tolua_function(tolua_S,"removeUnusedTextures",lua_cocos2dx_TextureCache_removeUnusedTextures);
|
||||
tolua_function(tolua_S,"removeTexture",lua_cocos2dx_TextureCache_removeTexture);
|
||||
|
|
|
@ -1599,6 +1599,13 @@ int register_all_cocos2dx(lua_State* tolua_S);
|
|||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -5348,6 +5348,59 @@ static int lua_cocos2dx_GLProgramState_setVertexAttribPointer(lua_State* tolua_S
|
|||
cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)arg5);
|
||||
return 0;
|
||||
}
|
||||
else if (argc == 7)
|
||||
{
|
||||
std::string arg0;
|
||||
int arg1;
|
||||
unsigned int arg2;
|
||||
bool arg3;
|
||||
int arg4;
|
||||
GLfloat* arg5;
|
||||
int arg6;
|
||||
|
||||
|
||||
ok &= luaval_to_std_string(tolua_S, 2,&arg0);
|
||||
|
||||
ok &= luaval_to_int32(tolua_S, 3,(int *)&arg1);
|
||||
|
||||
ok &= luaval_to_uint32(tolua_S, 4,&arg2);
|
||||
|
||||
ok &= luaval_to_boolean(tolua_S, 5, &arg3);
|
||||
|
||||
ok &= luaval_to_int32(tolua_S, 6,(int *)&arg4);
|
||||
|
||||
ok &= luaval_to_int32(tolua_S, 8, (int *)&arg6);
|
||||
|
||||
size_t len = lua_objlen(tolua_S, 7);
|
||||
|
||||
if (len != arg6)
|
||||
{
|
||||
CCLOG("table size is %zu,but input size is %d \n", len, arg6);
|
||||
return 0;
|
||||
}
|
||||
|
||||
arg5 = new GLfloat[len];
|
||||
for (int i = 0; i < len; i++)
|
||||
{
|
||||
lua_pushnumber(tolua_S,i + 1);
|
||||
lua_gettable(tolua_S,7);
|
||||
if (tolua_isnumber(tolua_S, -1, 0, &tolua_err))
|
||||
{
|
||||
arg5[i] = tolua_tonumber(tolua_S, -1, 0);
|
||||
}
|
||||
else
|
||||
{
|
||||
arg5[i] = 0;
|
||||
}
|
||||
lua_pop(tolua_S, 1);
|
||||
}
|
||||
|
||||
cobj->setVertexAttribPointer(arg0, arg1, arg2, arg3, arg4, (void*)arg5);
|
||||
|
||||
CC_SAFE_DELETE(arg5);
|
||||
|
||||
return 0;
|
||||
}
|
||||
CCLOG("%s has wrong number of arguments: %d, was expecting %d \n", "setVertexAttribPointer",argc, 6);
|
||||
return 0;
|
||||
|
||||
|
|
File diff suppressed because it is too large
Load Diff
|
@ -1195,4 +1195,13 @@ end
|
|||
rawset(ccui.Text,"getStringValue", TextBMFontDeprecated.getStringValue)
|
||||
--functions of ccui.TextBMFont will be deprecated begin
|
||||
|
||||
--functions of cc.ShaderCache will be deprecated begin
|
||||
local ShaderCacheDeprecated = { }
|
||||
function ShaderCacheDeprecated.getProgram(self,strShader)
|
||||
deprecatedTip("cc.ShaderCache:getProgram","cc.ShaderCache:getGLProgram")
|
||||
return self:getGLProgram(strShader)
|
||||
end
|
||||
rawset(cc.ShaderCache,"getProgram", ShaderCacheDeprecated.getProgram)
|
||||
--functions of ccui.TextBMFont will be deprecated begin
|
||||
|
||||
|
||||
|
|
|
@ -2187,4 +2187,22 @@ end
|
|||
_G["cc.EGLView"] = DeprecatedClass.EGLView()
|
||||
--EGLView class will be Deprecated,end
|
||||
|
||||
--EGLView class will be Deprecated,begin
|
||||
function DeprecatedClass.EGLView()
|
||||
deprecatedTip("cc.EGLView","cc.GLView")
|
||||
print(cc.GLView)
|
||||
return cc.GLView
|
||||
end
|
||||
_G["cc.EGLView"] = DeprecatedClass.EGLView()
|
||||
--EGLView class will be Deprecated,end
|
||||
|
||||
--ShaderCache class will be Deprecated,begin
|
||||
function DeprecatedClass.ShaderCache()
|
||||
deprecatedTip("cc.ShaderCache","cc.GLProgramCache")
|
||||
return cc.GLProgramCache
|
||||
end
|
||||
cc.ShaderCache = DeprecatedClass.ShaderCache()
|
||||
--ShaderCache class will be Deprecated,end
|
||||
|
||||
|
||||
|
||||
|
|
|
@ -9,6 +9,7 @@ LOCAL_SRC_FILES := \
|
|||
UIWidget.cpp \
|
||||
UILayout.cpp \
|
||||
UILayoutParameter.cpp \
|
||||
UILayoutExecutant.cpp \
|
||||
CocosGUI.cpp \
|
||||
UIHelper.cpp \
|
||||
UIListView.cpp \
|
||||
|
|
|
@ -8,6 +8,7 @@ set(COCOS_UI_SRC
|
|||
ui/UIImageView.cpp
|
||||
ui/UILayout.cpp
|
||||
ui/UILayoutParameter.cpp
|
||||
ui/UILayoutExecutant.cpp
|
||||
ui/UIListView.cpp
|
||||
ui/UILoadingBar.cpp
|
||||
ui/UIPageView.cpp
|
||||
|
|
|
@ -25,7 +25,6 @@
|
|||
#ifndef __TestCpp__GUIDefine__
|
||||
#define __TestCpp__GUIDefine__
|
||||
|
||||
#include "cocos2d.h"
|
||||
#include <string>
|
||||
#include "cocostudio/ObjectFactory.h"
|
||||
|
||||
|
|
|
@ -615,6 +615,9 @@ void CheckBox::copySpecialProperties(Widget *widget)
|
|||
loadTextureBackGroundDisabled(checkBox->_backGroundDisabledFileName, checkBox->_backGroundDisabledTexType);
|
||||
loadTextureFrontCrossDisabled(checkBox->_frontCrossDisabledFileName, checkBox->_frontCrossDisabledTexType);
|
||||
setSelectedState(checkBox->_isSelected);
|
||||
_checkBoxEventListener = checkBox->_checkBoxEventListener;
|
||||
_checkBoxEventSelector = checkBox->_checkBoxEventSelector;
|
||||
_checkBoxEventCallback = checkBox->_checkBoxEventCallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -22,7 +22,8 @@ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
|||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "CocosGUI.h"
|
||||
#include "ui/UIHelper.h"
|
||||
#include "ui/UIWidget.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
|
|
@ -25,9 +25,14 @@ THE SOFTWARE.
|
|||
#ifndef __UIHELPER_H__
|
||||
#define __UIHELPER_H__
|
||||
|
||||
#include <string>
|
||||
#include "base/CCPlatformMacros.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
class Widget;
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
|
|
|
@ -32,532 +32,12 @@ THE SOFTWARE.
|
|||
#include "renderer/CCRenderer.h"
|
||||
#include "renderer/CCGroupCommand.h"
|
||||
#include "renderer/CCCustomCommand.h"
|
||||
#include "ui/UILayoutExecutant.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
class LayoutExecutant : public Ref
|
||||
{
|
||||
public:
|
||||
LayoutExecutant(){};
|
||||
virtual ~LayoutExecutant(){};
|
||||
static LayoutExecutant* create();
|
||||
virtual void doLayout(const Size& layoutSize, Vector<Node*> container){};
|
||||
};
|
||||
|
||||
class LinearVerticalLayoutExecutant : public LayoutExecutant
|
||||
{
|
||||
public:
|
||||
LinearVerticalLayoutExecutant(){};
|
||||
virtual ~LinearVerticalLayoutExecutant(){};
|
||||
static LinearVerticalLayoutExecutant* create();
|
||||
virtual void doLayout(const Size& layoutSize, Vector<Node*> container);
|
||||
};
|
||||
|
||||
class LinearHorizontalLayoutExecutant : public LayoutExecutant
|
||||
{
|
||||
public:
|
||||
LinearHorizontalLayoutExecutant(){};
|
||||
virtual ~LinearHorizontalLayoutExecutant(){};
|
||||
static LinearHorizontalLayoutExecutant* create();
|
||||
virtual void doLayout(const Size& layoutSize, Vector<Node*> container);
|
||||
};
|
||||
|
||||
class RelativeLayoutExecutant : public LayoutExecutant
|
||||
{
|
||||
public:
|
||||
RelativeLayoutExecutant(){};
|
||||
virtual ~RelativeLayoutExecutant(){};
|
||||
static RelativeLayoutExecutant* create();
|
||||
virtual void doLayout(const Size& layoutSize, Vector<Node*> container);
|
||||
};
|
||||
|
||||
LayoutExecutant* LayoutExecutant::create()
|
||||
{
|
||||
LayoutExecutant* exe = new LayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LinearVerticalLayoutExecutant* LinearVerticalLayoutExecutant::create()
|
||||
{
|
||||
LinearVerticalLayoutExecutant* exe = new LinearVerticalLayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LinearHorizontalLayoutExecutant* LinearHorizontalLayoutExecutant::create()
|
||||
{
|
||||
LinearHorizontalLayoutExecutant* exe = new LinearHorizontalLayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RelativeLayoutExecutant* RelativeLayoutExecutant::create()
|
||||
{
|
||||
RelativeLayoutExecutant* exe = new RelativeLayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void LinearVerticalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector<cocos2d::Node *> container)
|
||||
{
|
||||
float topBoundary = layoutSize.height;
|
||||
|
||||
for (auto& subWidget : container)
|
||||
{
|
||||
Widget* child = dynamic_cast<Widget*>(subWidget);
|
||||
if (child)
|
||||
{
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::LINEAR));
|
||||
|
||||
if (layoutParameter)
|
||||
{
|
||||
LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Vec2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
float finalPosX = ap.x * cs.width;
|
||||
float finalPosY = topBoundary - ((1.0f-ap.y) * cs.height);
|
||||
switch (childGravity)
|
||||
{
|
||||
case LinearLayoutParameter::LinearGravity::NONE:
|
||||
case LinearLayoutParameter::LinearGravity::LEFT:
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::RIGHT:
|
||||
finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL:
|
||||
finalPosX = layoutSize.width / 2.0f - cs.width * (0.5f-ap.x);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Margin mg = layoutParameter->getMargin();
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
child->setPosition(Vec2(finalPosX, finalPosY));
|
||||
topBoundary = child->getBottomInParent() - mg.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LinearHorizontalLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector<cocos2d::Node *> container)
|
||||
{
|
||||
float leftBoundary = 0.0f;
|
||||
for (auto& subWidget : container)
|
||||
{
|
||||
Widget* child = dynamic_cast<Widget*>(subWidget);
|
||||
if (child)
|
||||
{
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::LINEAR));
|
||||
if (layoutParameter)
|
||||
{
|
||||
LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Vec2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
float finalPosX = leftBoundary + (ap.x * cs.width);
|
||||
float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height;
|
||||
switch (childGravity)
|
||||
{
|
||||
case LinearLayoutParameter::LinearGravity::NONE:
|
||||
case LinearLayoutParameter::LinearGravity::TOP:
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::BOTTOM:
|
||||
finalPosY = ap.y * cs.height;
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::CENTER_VERTICAL:
|
||||
finalPosY = layoutSize.height / 2.0f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Margin mg = layoutParameter->getMargin();
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
child->setPosition(Vec2(finalPosX, finalPosY));
|
||||
leftBoundary = child->getRightInParent() + mg.right;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void RelativeLayoutExecutant::doLayout(const cocos2d::Size &layoutSize, Vector<cocos2d::Node *> container)
|
||||
{
|
||||
ssize_t unlayoutChildCount = 0;
|
||||
Vector<Widget*> widgetChildren;
|
||||
for (auto& subWidget : container)
|
||||
{
|
||||
Widget* child = dynamic_cast<Widget*>(subWidget);
|
||||
if (child)
|
||||
{
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::RELATIVE));
|
||||
layoutParameter->_put = false;
|
||||
unlayoutChildCount++;
|
||||
widgetChildren.pushBack(child);
|
||||
}
|
||||
}
|
||||
while (unlayoutChildCount > 0)
|
||||
{
|
||||
for (auto& subWidget : widgetChildren)
|
||||
{
|
||||
Widget* child = static_cast<Widget*>(subWidget);
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::RELATIVE));
|
||||
|
||||
if (layoutParameter)
|
||||
{
|
||||
if (layoutParameter->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Vec2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
RelativeLayoutParameter::RelativeAlign align = layoutParameter->getAlign();
|
||||
const std::string relativeName = layoutParameter->getRelativeToWidgetName();
|
||||
Widget* relativeWidget = nullptr;
|
||||
RelativeLayoutParameter* relativeWidgetLP = nullptr;
|
||||
float finalPosX = 0.0f;
|
||||
float finalPosY = 0.0f;
|
||||
if (!relativeName.empty())
|
||||
{
|
||||
for (auto& sWidget : widgetChildren)
|
||||
{
|
||||
if (sWidget)
|
||||
{
|
||||
RelativeLayoutParameter* rlayoutParameter = dynamic_cast<RelativeLayoutParameter*>(sWidget->getLayoutParameter(LayoutParameter::Type::RELATIVE));
|
||||
if (rlayoutParameter && rlayoutParameter->getRelativeName() == relativeName)
|
||||
{
|
||||
relativeWidget = sWidget;
|
||||
relativeWidgetLP = rlayoutParameter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
switch (align)
|
||||
{
|
||||
case RelativeLayoutParameter::RelativeAlign::NONE:
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT:
|
||||
finalPosX = ap.x * cs.width;
|
||||
finalPosY = layoutSize.height - ((1.0f - ap.y) * cs.height);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL:
|
||||
finalPosX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x);
|
||||
finalPosY = layoutSize.height - ((1.0f - ap.y) * cs.height);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT:
|
||||
finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
finalPosY = layoutSize.height - ((1.0f - ap.y) * cs.height);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL:
|
||||
finalPosX = ap.x * cs.width;
|
||||
finalPosY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT:
|
||||
finalPosX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x);
|
||||
finalPosY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL:
|
||||
finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
finalPosY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM:
|
||||
finalPosX = ap.x * cs.width;
|
||||
finalPosY = ap.y * cs.height;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL:
|
||||
finalPosX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x);
|
||||
finalPosY = ap.y * cs.height;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM:
|
||||
finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
finalPosY = ap.y * cs.height;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_LEFTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationBottom = relativeWidget->getTopInParent();
|
||||
float locationLeft = relativeWidget->getLeftInParent();
|
||||
finalPosY = locationBottom + ap.y * cs.height;
|
||||
finalPosX = locationLeft + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationBottom = relativeWidget->getTopInParent();
|
||||
|
||||
finalPosY = locationBottom + ap.y * cs.height;
|
||||
finalPosX = relativeWidget->getLeftInParent() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationBottom = relativeWidget->getTopInParent();
|
||||
float locationRight = relativeWidget->getRightInParent();
|
||||
finalPosY = locationBottom + ap.y * cs.height;
|
||||
finalPosX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_TOPALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationTop = relativeWidget->getTopInParent();
|
||||
float locationRight = relativeWidget->getLeftInParent();
|
||||
finalPosY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
finalPosX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationRight = relativeWidget->getLeftInParent();
|
||||
finalPosX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
|
||||
finalPosY = relativeWidget->getBottomInParent() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_BOTTOMALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationBottom = relativeWidget->getBottomInParent();
|
||||
float locationRight = relativeWidget->getLeftInParent();
|
||||
finalPosY = locationBottom + ap.y * cs.height;
|
||||
finalPosX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_TOPALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationTop = relativeWidget->getTopInParent();
|
||||
float locationLeft = relativeWidget->getRightInParent();
|
||||
finalPosY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
finalPosX = locationLeft + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationLeft = relativeWidget->getRightInParent();
|
||||
finalPosX = locationLeft + ap.x * cs.width;
|
||||
|
||||
finalPosY = relativeWidget->getBottomInParent() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_BOTTOMALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationBottom = relativeWidget->getBottomInParent();
|
||||
float locationLeft = relativeWidget->getRightInParent();
|
||||
finalPosY = locationBottom + ap.y * cs.height;
|
||||
finalPosX = locationLeft + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_LEFTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationTop = relativeWidget->getBottomInParent();
|
||||
float locationLeft = relativeWidget->getLeftInParent();
|
||||
finalPosY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
finalPosX = locationLeft + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationTop = relativeWidget->getBottomInParent();
|
||||
|
||||
finalPosY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
finalPosX = relativeWidget->getLeftInParent() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_RIGHTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (relativeWidgetLP && !relativeWidgetLP->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
float locationTop = relativeWidget->getBottomInParent();
|
||||
float locationRight = relativeWidget->getRightInParent();
|
||||
finalPosY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
finalPosX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Margin relativeWidgetMargin;
|
||||
Margin mg = layoutParameter->getMargin();
|
||||
if (relativeWidgetLP)
|
||||
{
|
||||
relativeWidgetMargin = relativeWidgetLP->getMargin();
|
||||
}
|
||||
//handle margin
|
||||
switch (align)
|
||||
{
|
||||
case RelativeLayoutParameter::RelativeAlign::NONE:
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT:
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL:
|
||||
finalPosY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT:
|
||||
finalPosX -= mg.right;
|
||||
finalPosY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL:
|
||||
finalPosX += mg.left;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT:
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL:
|
||||
finalPosX -= mg.right;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM:
|
||||
finalPosX += mg.left;
|
||||
finalPosY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL:
|
||||
finalPosY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM:
|
||||
finalPosX -= mg.right;
|
||||
finalPosY += mg.bottom;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_LEFTALIGN:
|
||||
finalPosY += mg.bottom;
|
||||
finalPosX += mg.left;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN:
|
||||
finalPosY += mg.bottom;
|
||||
finalPosX -= mg.right;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER:
|
||||
finalPosY += mg.bottom;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_TOPALIGN:
|
||||
finalPosX -= mg.right;
|
||||
finalPosY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_BOTTOMALIGN:
|
||||
finalPosX -= mg.right;
|
||||
finalPosY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER:
|
||||
finalPosX -= mg.right;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_TOPALIGN:
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_BOTTOMALIGN:
|
||||
finalPosX += mg.left;
|
||||
finalPosY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER:
|
||||
finalPosX += mg.left;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_LEFTALIGN:
|
||||
finalPosY -= mg.top;
|
||||
finalPosX += mg.left;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_RIGHTALIGN:
|
||||
finalPosY -= mg.top;
|
||||
finalPosX -= mg.right;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER:
|
||||
finalPosY -= mg.top;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
child->setPosition(Vec2(finalPosX, finalPosY));
|
||||
layoutParameter->_put = true;
|
||||
unlayoutChildCount--;
|
||||
}
|
||||
}
|
||||
}
|
||||
widgetChildren.clear();
|
||||
}
|
||||
|
||||
static const int BACKGROUNDIMAGE_Z = (-1);
|
||||
static const int BCAKGROUNDCOLORRENDERER_Z = (-2);
|
||||
|
||||
|
@ -604,7 +84,6 @@ _currentAlphaTestFunc(GL_ALWAYS),
|
|||
_currentAlphaTestRef(1),
|
||||
_backGroundImageColor(Color3B::WHITE),
|
||||
_backGroundImageOpacity(255),
|
||||
_curLayoutExecutant(nullptr),
|
||||
_passFocusToChild(true),
|
||||
_loopFocus(false)
|
||||
{
|
||||
|
@ -615,7 +94,6 @@ _loopFocus(false)
|
|||
Layout::~Layout()
|
||||
{
|
||||
CC_SAFE_RELEASE(_clippingStencil);
|
||||
CC_SAFE_RELEASE(_curLayoutExecutant);
|
||||
}
|
||||
|
||||
void Layout::onEnter()
|
||||
|
@ -1182,7 +660,7 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child)
|
|||
case Type::HORIZONTAL:
|
||||
case Type::VERTICAL:
|
||||
{
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::LINEAR));
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter());
|
||||
if (!layoutParameter)
|
||||
{
|
||||
child->setLayoutParameter(LinearLayoutParameter::create());
|
||||
|
@ -1191,7 +669,7 @@ void Layout::supplyTheLayoutParameterLackToChild(Widget *child)
|
|||
}
|
||||
case Type::RELATIVE:
|
||||
{
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(child->getLayoutParameter(LayoutParameter::Type::RELATIVE));
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(child->getLayoutParameter());
|
||||
if (!layoutParameter)
|
||||
{
|
||||
child->setLayoutParameter(RelativeLayoutParameter::create());
|
||||
|
@ -1429,9 +907,7 @@ const Size& Layout::getBackGroundImageTextureSize() const
|
|||
void Layout::setLayoutType(Type type)
|
||||
{
|
||||
_layoutType = type;
|
||||
CC_SAFE_RELEASE_NULL(_curLayoutExecutant);
|
||||
_curLayoutExecutant = createCurrentLayoutExecutant();
|
||||
CC_SAFE_RETAIN(_curLayoutExecutant);
|
||||
|
||||
for (auto& child : _children)
|
||||
{
|
||||
Widget* widgetChild = dynamic_cast<Widget*>(child);
|
||||
|
@ -1443,7 +919,29 @@ void Layout::setLayoutType(Type type)
|
|||
_doLayoutDirty = true;
|
||||
}
|
||||
|
||||
LayoutExecutant* Layout::createCurrentLayoutExecutant()
|
||||
|
||||
|
||||
Layout::Type Layout::getLayoutType() const
|
||||
{
|
||||
return _layoutType;
|
||||
}
|
||||
|
||||
void Layout::requestDoLayout()
|
||||
{
|
||||
_doLayoutDirty = true;
|
||||
}
|
||||
|
||||
const Size Layout::getLayoutContentSize()
|
||||
{
|
||||
return this->getSize();
|
||||
}
|
||||
|
||||
const Vector<Node*>& Layout::getLayoutElements()
|
||||
{
|
||||
return this->getChildren();
|
||||
}
|
||||
|
||||
LayoutExecutant* Layout::createLayoutExecutant()
|
||||
{
|
||||
LayoutExecutant* exe = nullptr;
|
||||
switch (_layoutType)
|
||||
|
@ -1461,16 +959,7 @@ LayoutExecutant* Layout::createCurrentLayoutExecutant()
|
|||
break;
|
||||
}
|
||||
return exe;
|
||||
}
|
||||
|
||||
Layout::Type Layout::getLayoutType() const
|
||||
{
|
||||
return _layoutType;
|
||||
}
|
||||
|
||||
void Layout::requestDoLayout()
|
||||
{
|
||||
_doLayoutDirty = true;
|
||||
}
|
||||
|
||||
void Layout::doLayout()
|
||||
|
@ -1479,10 +968,13 @@ void Layout::doLayout()
|
|||
{
|
||||
return;
|
||||
}
|
||||
if (_curLayoutExecutant)
|
||||
LayoutExecutant* executant = this->createLayoutExecutant();
|
||||
|
||||
if (executant)
|
||||
{
|
||||
_curLayoutExecutant->doLayout(getSize(), getChildren());
|
||||
executant->doLayout(this);
|
||||
}
|
||||
|
||||
_doLayoutDirty = false;
|
||||
}
|
||||
|
||||
|
@ -1517,6 +1009,8 @@ void Layout::copySpecialProperties(Widget *widget)
|
|||
setLayoutType(layout->_layoutType);
|
||||
setClippingEnabled(layout->_clippingEnabled);
|
||||
setClippingType(layout->_clippingType);
|
||||
_loopFocus = layout->_loopFocus;
|
||||
_passFocusToChild = layout->_passFocusToChild;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1541,7 +1035,7 @@ bool Layout::isPassFocusToChild()
|
|||
return _passFocusToChild;
|
||||
}
|
||||
|
||||
Size Layout::getLayoutContentSize()const
|
||||
Size Layout::getLayoutAccumulatedSize()const
|
||||
{
|
||||
const auto& children = this->getChildren();
|
||||
Size layoutSize = Size::ZERO;
|
||||
|
@ -1551,7 +1045,7 @@ Size Layout::getLayoutContentSize()const
|
|||
Layout *layout = dynamic_cast<Layout*>(widget);
|
||||
if (nullptr != layout)
|
||||
{
|
||||
layoutSize = layoutSize + layout->getLayoutContentSize();
|
||||
layoutSize = layoutSize + layout->getLayoutAccumulatedSize();
|
||||
}
|
||||
else
|
||||
{
|
||||
|
@ -1559,7 +1053,7 @@ Size Layout::getLayoutContentSize()const
|
|||
if (w)
|
||||
{
|
||||
widgetCount++;
|
||||
Margin m = w->getLayoutParameter(LayoutParameter::Type::LINEAR)->getMargin();
|
||||
Margin m = w->getLayoutParameter()->getMargin();
|
||||
layoutSize = layoutSize + w->getSize() + Size(m.right + m.left, m.top + m.bottom) * 0.5;
|
||||
}
|
||||
}
|
||||
|
@ -1582,7 +1076,7 @@ Vec2 Layout::getWorldCenterPoint(Widget* widget)
|
|||
{
|
||||
Layout *layout = dynamic_cast<Layout*>(widget);
|
||||
//FIXEDME: we don't need to calculate the content size of layout anymore
|
||||
Size widgetSize = layout ? layout->getLayoutContentSize() : widget->getSize();
|
||||
Size widgetSize = layout ? layout->getLayoutAccumulatedSize() : widget->getSize();
|
||||
// CCLOG("contnet size : width = %f, height = %f", widgetSize.width, widgetSize.height);
|
||||
return widget->convertToWorldSpace(Vec2(widgetSize.width/2, widgetSize.height/2));
|
||||
}
|
||||
|
|
|
@ -30,14 +30,27 @@ THE SOFTWARE.
|
|||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
class LayoutExecutant;
|
||||
|
||||
class LayoutProtocol
|
||||
{
|
||||
public:
|
||||
LayoutProtocol(){}
|
||||
virtual ~LayoutProtocol(){}
|
||||
|
||||
virtual LayoutExecutant* createLayoutExecutant() = 0;
|
||||
virtual const Size getLayoutContentSize() = 0;
|
||||
virtual const Vector<Node*>& getLayoutElements() = 0;
|
||||
virtual void doLayout() = 0;
|
||||
};
|
||||
|
||||
/**
|
||||
* @js NA
|
||||
* @lua NA
|
||||
*/
|
||||
class LayoutExecutant;
|
||||
|
||||
class Layout : public Widget
|
||||
class Layout : public Widget, public LayoutProtocol
|
||||
{
|
||||
|
||||
DECLARE_CLASS_GUI_INFO
|
||||
|
@ -313,7 +326,11 @@ protected:
|
|||
|
||||
void setStencilClippingSize(const Size& size);
|
||||
const Rect& getClippingRect();
|
||||
virtual void doLayout();
|
||||
|
||||
virtual void doLayout()override;
|
||||
virtual LayoutExecutant* createLayoutExecutant()override;
|
||||
virtual const Size getLayoutContentSize()override;
|
||||
virtual const Vector<Node*>& getLayoutElements() override;
|
||||
|
||||
//clipping
|
||||
void onBeforeVisitStencil();
|
||||
|
@ -325,12 +342,11 @@ protected:
|
|||
void updateBackGroundImageColor();
|
||||
void updateBackGroundImageOpacity();
|
||||
void updateBackGroundImageRGBA();
|
||||
LayoutExecutant* createCurrentLayoutExecutant();
|
||||
|
||||
/**
|
||||
*get the content size of the layout, it will accumulate all its children's content size
|
||||
*/
|
||||
Size getLayoutContentSize() const;
|
||||
Size getLayoutAccumulatedSize() const;
|
||||
|
||||
/**
|
||||
* When the layout get focused, it the layout pass the focus to its child, it will use this method to determine which child
|
||||
|
@ -477,8 +493,6 @@ protected:
|
|||
Color3B _backGroundImageColor;
|
||||
GLubyte _backGroundImageOpacity;
|
||||
|
||||
LayoutExecutant* _curLayoutExecutant;
|
||||
|
||||
GLint _mask_layer_le;
|
||||
GroupCommand _groupCommand;
|
||||
CustomCommand _beforeVisitCmdStencil;
|
||||
|
|
|
@ -0,0 +1,559 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#include "UILayoutExecutant.h"
|
||||
#include "UILayout.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
LinearVerticalLayoutExecutant* LinearVerticalLayoutExecutant::create()
|
||||
{
|
||||
LinearVerticalLayoutExecutant* exe = new LinearVerticalLayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
LinearHorizontalLayoutExecutant* LinearHorizontalLayoutExecutant::create()
|
||||
{
|
||||
LinearHorizontalLayoutExecutant* exe = new LinearHorizontalLayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
RelativeLayoutExecutant* RelativeLayoutExecutant::create()
|
||||
{
|
||||
RelativeLayoutExecutant* exe = new RelativeLayoutExecutant();
|
||||
if (exe)
|
||||
{
|
||||
exe->autorelease();
|
||||
return exe;
|
||||
}
|
||||
CC_SAFE_DELETE(exe);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
void LinearVerticalLayoutExecutant::doLayout(LayoutProtocol* layout)
|
||||
{
|
||||
Size layoutSize = layout->getLayoutContentSize();
|
||||
Vector<Node*> container = layout->getLayoutElements();
|
||||
float topBoundary = layoutSize.height;
|
||||
|
||||
for (auto& subWidget : container)
|
||||
{
|
||||
LayoutParameterProtocol* child = dynamic_cast<LayoutParameterProtocol*>(subWidget);
|
||||
if (child)
|
||||
{
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter());
|
||||
|
||||
if (layoutParameter)
|
||||
{
|
||||
LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Vec2 ap = subWidget->getAnchorPoint();
|
||||
Size cs = subWidget->getContentSize();
|
||||
float finalPosX = ap.x * cs.width;
|
||||
float finalPosY = topBoundary - ((1.0f-ap.y) * cs.height);
|
||||
switch (childGravity)
|
||||
{
|
||||
case LinearLayoutParameter::LinearGravity::NONE:
|
||||
case LinearLayoutParameter::LinearGravity::LEFT:
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::RIGHT:
|
||||
finalPosX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::CENTER_HORIZONTAL:
|
||||
finalPosX = layoutSize.width / 2.0f - cs.width * (0.5f-ap.x);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Margin mg = layoutParameter->getMargin();
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
subWidget->setPosition(Vec2(finalPosX, finalPosY));
|
||||
topBoundary = subWidget->getPosition().y - subWidget->getAnchorPoint().y * subWidget->getContentSize().height - mg.bottom;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void LinearHorizontalLayoutExecutant::doLayout(LayoutProtocol* layout)
|
||||
{
|
||||
Size layoutSize = layout->getLayoutContentSize();
|
||||
Vector<Node*> container = layout->getLayoutElements();
|
||||
float leftBoundary = 0.0f;
|
||||
for (auto& subWidget : container)
|
||||
{
|
||||
Widget* child = dynamic_cast<Widget*>(subWidget);
|
||||
if (child)
|
||||
{
|
||||
LinearLayoutParameter* layoutParameter = dynamic_cast<LinearLayoutParameter*>(child->getLayoutParameter());
|
||||
if (layoutParameter)
|
||||
{
|
||||
LinearLayoutParameter::LinearGravity childGravity = layoutParameter->getGravity();
|
||||
Vec2 ap = child->getAnchorPoint();
|
||||
Size cs = child->getSize();
|
||||
float finalPosX = leftBoundary + (ap.x * cs.width);
|
||||
float finalPosY = layoutSize.height - (1.0f - ap.y) * cs.height;
|
||||
switch (childGravity)
|
||||
{
|
||||
case LinearLayoutParameter::LinearGravity::NONE:
|
||||
case LinearLayoutParameter::LinearGravity::TOP:
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::BOTTOM:
|
||||
finalPosY = ap.y * cs.height;
|
||||
break;
|
||||
case LinearLayoutParameter::LinearGravity::CENTER_VERTICAL:
|
||||
finalPosY = layoutSize.height / 2.0f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
Margin mg = layoutParameter->getMargin();
|
||||
finalPosX += mg.left;
|
||||
finalPosY -= mg.top;
|
||||
child->setPosition(Vec2(finalPosX, finalPosY));
|
||||
leftBoundary = child->getRightBoundary() + mg.right;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Vector<Widget*> RelativeLayoutExecutant::getAllWidgets(cocos2d::ui::LayoutProtocol *layout)
|
||||
{
|
||||
Vector<Node*> container = layout->getLayoutElements();
|
||||
Vector<Widget*> widgetChildren;
|
||||
for (auto& subWidget : container)
|
||||
{
|
||||
Widget* child = dynamic_cast<Widget*>(subWidget);
|
||||
if (child)
|
||||
{
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(child->getLayoutParameter());
|
||||
layoutParameter->_put = false;
|
||||
_unlayoutChildCount++;
|
||||
widgetChildren.pushBack(child);
|
||||
}
|
||||
}
|
||||
return widgetChildren;
|
||||
|
||||
}
|
||||
|
||||
Widget* RelativeLayoutExecutant::getRelativeWidget(Widget* widget)
|
||||
{
|
||||
Widget* relativeWidget = nullptr;
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(widget->getLayoutParameter());
|
||||
const std::string relativeName = layoutParameter->getRelativeToWidgetName();
|
||||
|
||||
if (!relativeName.empty())
|
||||
{
|
||||
for (auto& sWidget : _widgetChildren)
|
||||
{
|
||||
if (sWidget)
|
||||
{
|
||||
RelativeLayoutParameter* rlayoutParameter = dynamic_cast<RelativeLayoutParameter*>(sWidget->getLayoutParameter());
|
||||
if (rlayoutParameter && rlayoutParameter->getRelativeName() == relativeName)
|
||||
{
|
||||
relativeWidget = sWidget;
|
||||
_relativeWidgetLP = rlayoutParameter;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
return relativeWidget;
|
||||
}
|
||||
|
||||
bool RelativeLayoutExecutant::caculateFinalPositionWithRelativeWidget(LayoutProtocol *layout)
|
||||
{
|
||||
Vec2 ap = _widget->getAnchorPoint();
|
||||
Size cs = _widget->getSize();
|
||||
|
||||
_finalPositionX = 0.0f;
|
||||
_finalPositionY = 0.0f;
|
||||
|
||||
Widget* relativeWidget = this->getRelativeWidget(_widget);
|
||||
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(_widget->getLayoutParameter());
|
||||
|
||||
RelativeLayoutParameter::RelativeAlign align = layoutParameter->getAlign();
|
||||
|
||||
Size layoutSize = layout->getLayoutContentSize();
|
||||
|
||||
|
||||
switch (align)
|
||||
{
|
||||
case RelativeLayoutParameter::RelativeAlign::NONE:
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT:
|
||||
_finalPositionX = ap.x * cs.width;
|
||||
_finalPositionY = layoutSize.height - ((1.0f - ap.y) * cs.height);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL:
|
||||
_finalPositionX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x);
|
||||
_finalPositionY = layoutSize.height - ((1.0f - ap.y) * cs.height);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT:
|
||||
_finalPositionX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
_finalPositionY = layoutSize.height - ((1.0f - ap.y) * cs.height);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL:
|
||||
_finalPositionX = ap.x * cs.width;
|
||||
_finalPositionY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT:
|
||||
_finalPositionX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x);
|
||||
_finalPositionY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL:
|
||||
_finalPositionX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
_finalPositionY = layoutSize.height * 0.5f - cs.height * (0.5f - ap.y);
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM:
|
||||
_finalPositionX = ap.x * cs.width;
|
||||
_finalPositionY = ap.y * cs.height;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL:
|
||||
_finalPositionX = layoutSize.width * 0.5f - cs.width * (0.5f - ap.x);
|
||||
_finalPositionY = ap.y * cs.height;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM:
|
||||
_finalPositionX = layoutSize.width - ((1.0f - ap.x) * cs.width);
|
||||
_finalPositionY = ap.y * cs.height;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_LEFTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationTop = relativeWidget->getTopBoundary();
|
||||
float locationLeft = relativeWidget->getLeftBoundary();
|
||||
_finalPositionY = locationTop + ap.y * cs.height;
|
||||
_finalPositionX = locationLeft + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationTop = relativeWidget->getTopBoundary();
|
||||
|
||||
_finalPositionY = locationTop + ap.y * cs.height;
|
||||
_finalPositionX = relativeWidget->getLeftBoundary() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationTop = relativeWidget->getTopBoundary();
|
||||
float locationRight = relativeWidget->getRightBoundary();
|
||||
_finalPositionY = locationTop + ap.y * cs.height;
|
||||
_finalPositionX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_TOPALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationTop = relativeWidget->getTopBoundary();
|
||||
float locationLeft = relativeWidget->getLeftBoundary();
|
||||
_finalPositionY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
_finalPositionX = locationLeft - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationLeft = relativeWidget->getLeftBoundary();
|
||||
_finalPositionX = locationLeft - (1.0f - ap.x) * cs.width;
|
||||
|
||||
_finalPositionY = relativeWidget->getBottomBoundary() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_BOTTOMALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationBottom = relativeWidget->getBottomBoundary();
|
||||
float locationLeft = relativeWidget->getLeftBoundary();
|
||||
_finalPositionY = locationBottom + ap.y * cs.height;
|
||||
_finalPositionX = locationLeft - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_TOPALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationTop = relativeWidget->getTopBoundary();
|
||||
float locationRight = relativeWidget->getRightBoundary();
|
||||
_finalPositionY = locationTop - (1.0f - ap.y) * cs.height;
|
||||
_finalPositionX = locationRight + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationRight = relativeWidget->getRightBoundary();
|
||||
_finalPositionX = locationRight + ap.x * cs.width;
|
||||
|
||||
_finalPositionY = relativeWidget->getBottomBoundary() + rbs.height * 0.5f + ap.y * cs.height - cs.height * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_BOTTOMALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationBottom = relativeWidget->getBottomBoundary();
|
||||
float locationRight = relativeWidget->getRightBoundary();
|
||||
_finalPositionY = locationBottom + ap.y * cs.height;
|
||||
_finalPositionX = locationRight + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_LEFTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationBottom = relativeWidget->getBottomBoundary();
|
||||
float locationLeft = relativeWidget->getLeftBoundary();
|
||||
_finalPositionY = locationBottom - (1.0f - ap.y) * cs.height;
|
||||
_finalPositionX = locationLeft + ap.x * cs.width;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
Size rbs = relativeWidget->getSize();
|
||||
float locationBottom = relativeWidget->getBottomBoundary();
|
||||
|
||||
_finalPositionY = locationBottom - (1.0f - ap.y) * cs.height;
|
||||
_finalPositionX = relativeWidget->getLeftBoundary() + rbs.width * 0.5f + ap.x * cs.width - cs.width * 0.5f;
|
||||
}
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_RIGHTALIGN:
|
||||
if (relativeWidget)
|
||||
{
|
||||
if (_relativeWidgetLP && !_relativeWidgetLP->_put)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
float locationBottom = relativeWidget->getBottomBoundary();
|
||||
float locationRight = relativeWidget->getRightBoundary();
|
||||
_finalPositionY = locationBottom - (1.0f - ap.y) * cs.height;
|
||||
_finalPositionX = locationRight - (1.0f - ap.x) * cs.width;
|
||||
}
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
void RelativeLayoutExecutant::caculateFinalPositionWithRelativeAlign()
|
||||
{
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(_widget->getLayoutParameter());
|
||||
|
||||
Margin mg = layoutParameter->getMargin();
|
||||
|
||||
|
||||
RelativeLayoutParameter::RelativeAlign align = layoutParameter->getAlign();
|
||||
|
||||
//handle margin
|
||||
switch (align)
|
||||
{
|
||||
case RelativeLayoutParameter::RelativeAlign::NONE:
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_LEFT:
|
||||
_finalPositionX += mg.left;
|
||||
_finalPositionY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_CENTER_HORIZONTAL:
|
||||
_finalPositionY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_TOP_RIGHT:
|
||||
_finalPositionX -= mg.right;
|
||||
_finalPositionY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_CENTER_VERTICAL:
|
||||
_finalPositionX += mg.left;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::CENTER_IN_PARENT:
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_CENTER_VERTICAL:
|
||||
_finalPositionX -= mg.right;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_LEFT_BOTTOM:
|
||||
_finalPositionX += mg.left;
|
||||
_finalPositionY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_BOTTOM_CENTER_HORIZONTAL:
|
||||
_finalPositionY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::PARENT_RIGHT_BOTTOM:
|
||||
_finalPositionX -= mg.right;
|
||||
_finalPositionY += mg.bottom;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_LEFTALIGN:
|
||||
_finalPositionY += mg.bottom;
|
||||
_finalPositionX += mg.left;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_RIGHTALIGN:
|
||||
_finalPositionY += mg.bottom;
|
||||
_finalPositionX -= mg.right;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_ABOVE_CENTER:
|
||||
_finalPositionY += mg.bottom;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_TOPALIGN:
|
||||
_finalPositionX -= mg.right;
|
||||
_finalPositionY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_BOTTOMALIGN:
|
||||
_finalPositionX -= mg.right;
|
||||
_finalPositionY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_LEFT_OF_CENTER:
|
||||
_finalPositionX -= mg.right;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_TOPALIGN:
|
||||
_finalPositionX += mg.left;
|
||||
_finalPositionY -= mg.top;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_BOTTOMALIGN:
|
||||
_finalPositionX += mg.left;
|
||||
_finalPositionY += mg.bottom;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_RIGHT_OF_CENTER:
|
||||
_finalPositionX += mg.left;
|
||||
break;
|
||||
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_LEFTALIGN:
|
||||
_finalPositionY -= mg.top;
|
||||
_finalPositionX += mg.left;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_RIGHTALIGN:
|
||||
_finalPositionY -= mg.top;
|
||||
_finalPositionX -= mg.right;
|
||||
break;
|
||||
case RelativeLayoutParameter::RelativeAlign::LOCATION_BELOW_CENTER:
|
||||
_finalPositionY -= mg.top;
|
||||
break;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void RelativeLayoutExecutant::doLayout(LayoutProtocol *layout)
|
||||
{
|
||||
|
||||
_widgetChildren = this->getAllWidgets(layout);
|
||||
|
||||
while (_unlayoutChildCount > 0)
|
||||
{
|
||||
for (auto& subWidget : _widgetChildren)
|
||||
{
|
||||
_widget = static_cast<Widget*>(subWidget);
|
||||
|
||||
RelativeLayoutParameter* layoutParameter = dynamic_cast<RelativeLayoutParameter*>(_widget->getLayoutParameter());
|
||||
|
||||
if (layoutParameter)
|
||||
{
|
||||
if (layoutParameter->_put)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
bool ret = this->caculateFinalPositionWithRelativeWidget(layout);
|
||||
if (!ret) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this->caculateFinalPositionWithRelativeAlign();
|
||||
|
||||
|
||||
_widget->setPosition(Vec2(_finalPositionX, _finalPositionY));
|
||||
|
||||
layoutParameter->_put = true;
|
||||
}
|
||||
}
|
||||
_unlayoutChildCount--;
|
||||
|
||||
}
|
||||
_widgetChildren.clear();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
|
@ -0,0 +1,98 @@
|
|||
/****************************************************************************
|
||||
Copyright (c) 2013-2014 Chukong Technologies Inc.
|
||||
|
||||
http://www.cocos2d-x.org
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
of this software and associated documentation files (the "Software"), to deal
|
||||
in the Software without restriction, including without limitation the rights
|
||||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
copies of the Software, and to permit persons to whom the Software is
|
||||
furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in
|
||||
all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
THE SOFTWARE.
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __cocos2d_libs__CCLayoutExecutant__
|
||||
#define __cocos2d_libs__CCLayoutExecutant__
|
||||
|
||||
#include "base/CCRef.h"
|
||||
#include "base/CCVector.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
namespace ui {
|
||||
|
||||
class LayoutProtocol;
|
||||
class Widget;
|
||||
class RelativeLayoutParameter;
|
||||
|
||||
class LayoutExecutant : public Ref
|
||||
{
|
||||
public:
|
||||
LayoutExecutant(){};
|
||||
virtual ~LayoutExecutant(){};
|
||||
|
||||
virtual void doLayout(LayoutProtocol *layout) = 0;
|
||||
};
|
||||
|
||||
class LinearVerticalLayoutExecutant : public LayoutExecutant
|
||||
{
|
||||
public:
|
||||
LinearVerticalLayoutExecutant(){};
|
||||
virtual ~LinearVerticalLayoutExecutant(){};
|
||||
static LinearVerticalLayoutExecutant* create();
|
||||
virtual void doLayout(LayoutProtocol *layout) override;
|
||||
};
|
||||
|
||||
class LinearHorizontalLayoutExecutant : public LayoutExecutant
|
||||
{
|
||||
public:
|
||||
LinearHorizontalLayoutExecutant(){};
|
||||
virtual ~LinearHorizontalLayoutExecutant(){};
|
||||
static LinearHorizontalLayoutExecutant* create();
|
||||
virtual void doLayout(LayoutProtocol *layout) override;
|
||||
};
|
||||
|
||||
class RelativeLayoutExecutant : public LayoutExecutant
|
||||
{
|
||||
public:
|
||||
RelativeLayoutExecutant()
|
||||
:_unlayoutChildCount(0),
|
||||
_widget(nullptr),
|
||||
_finalPositionX(0.0f),
|
||||
_finalPositionY(0.0f),
|
||||
_relativeWidgetLP(nullptr)
|
||||
{}
|
||||
virtual ~RelativeLayoutExecutant(){};
|
||||
static RelativeLayoutExecutant* create();
|
||||
virtual void doLayout(LayoutProtocol *layout) override;
|
||||
|
||||
protected:
|
||||
Vector<Widget*> getAllWidgets(LayoutProtocol *layout);
|
||||
Widget* getRelativeWidget(Widget* widget);
|
||||
bool caculateFinalPositionWithRelativeWidget(LayoutProtocol *layout);
|
||||
void caculateFinalPositionWithRelativeAlign();
|
||||
|
||||
ssize_t _unlayoutChildCount;
|
||||
Vector<Widget*> _widgetChildren;
|
||||
Widget* _widget;
|
||||
float _finalPositionX;
|
||||
float _finalPositionY;
|
||||
|
||||
RelativeLayoutParameter* _relativeWidgetLP;
|
||||
};
|
||||
|
||||
}
|
||||
|
||||
NS_CC_END
|
||||
#endif /* defined(__cocos2d_libs__CCLayoutExecutant__) */
|
|
@ -129,6 +129,15 @@ protected:
|
|||
Margin _margin;
|
||||
Type _layoutParameterType;
|
||||
};
|
||||
|
||||
class LayoutParameterProtocol
|
||||
{
|
||||
public:
|
||||
LayoutParameterProtocol(){}
|
||||
virtual ~LayoutParameterProtocol(){}
|
||||
|
||||
virtual LayoutParameter* getLayoutParameter() = 0;
|
||||
};
|
||||
|
||||
|
||||
/**
|
||||
|
|
|
@ -130,7 +130,7 @@ void ListView::remedyLayoutParameter(Widget *item)
|
|||
switch (_direction) {
|
||||
case Direction::VERTICAL:
|
||||
{
|
||||
LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LayoutParameter::Type::LINEAR));
|
||||
LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter());
|
||||
if (!llp)
|
||||
{
|
||||
LinearLayoutParameter* defaultLp = LinearLayoutParameter::create();
|
||||
|
@ -185,7 +185,7 @@ void ListView::remedyLayoutParameter(Widget *item)
|
|||
}
|
||||
case Direction::HORIZONTAL:
|
||||
{
|
||||
LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter(LayoutParameter::Type::LINEAR));
|
||||
LinearLayoutParameter* llp = (LinearLayoutParameter*)(item->getLayoutParameter());
|
||||
if (!llp)
|
||||
{
|
||||
LinearLayoutParameter* defaultLp = LinearLayoutParameter::create();
|
||||
|
@ -546,6 +546,9 @@ void ListView::copySpecialProperties(Widget *widget)
|
|||
setItemModel(listViewEx->_model);
|
||||
setItemsMargin(listViewEx->_itemsMargin);
|
||||
setGravity(listViewEx->_gravity);
|
||||
_listViewEventListener = listViewEx->_listViewEventListener;
|
||||
_listViewEventSelector = listViewEx->_listViewEventSelector;
|
||||
_eventCallback = listViewEx->_eventCallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -403,18 +403,20 @@ bool PageView::scrollPages(float touchOffset)
|
|||
switch (_touchMoveDirection)
|
||||
{
|
||||
case TouchDirection::LEFT: // left
|
||||
if (_rightBoundaryChild->getRightInParent() + touchOffset <= _rightBoundary)
|
||||
|
||||
if (_rightBoundaryChild->getRightBoundary() + touchOffset <= _rightBoundary)
|
||||
{
|
||||
realOffset = _rightBoundary - _rightBoundaryChild->getRightInParent();
|
||||
realOffset = _rightBoundary - _rightBoundaryChild->getRightBoundary();
|
||||
movePages(realOffset);
|
||||
return false;
|
||||
}
|
||||
break;
|
||||
|
||||
case TouchDirection::RIGHT: // right
|
||||
if (_leftBoundaryChild->getLeftInParent() + touchOffset >= _leftBoundary)
|
||||
|
||||
if (_leftBoundaryChild->getLeftBoundary() + touchOffset >= _leftBoundary)
|
||||
{
|
||||
realOffset = _leftBoundary - _leftBoundaryChild->getLeftInParent();
|
||||
realOffset = _leftBoundary - _leftBoundaryChild->getLeftBoundary();
|
||||
movePages(realOffset);
|
||||
return false;
|
||||
}
|
||||
|
@ -591,6 +593,9 @@ void PageView::copySpecialProperties(Widget *widget)
|
|||
if (pageView)
|
||||
{
|
||||
Layout::copySpecialProperties(widget);
|
||||
_eventCallback = pageView->_eventCallback;
|
||||
_pageViewEventListener = pageView->_pageViewEventListener;
|
||||
_pageViewEventSelector = pageView->_pageViewEventSelector;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -49,7 +49,7 @@ ScrollInnerContainer* ScrollInnerContainer::create()
|
|||
CC_SAFE_DELETE(widget);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
|
||||
const Size& ScrollInnerContainer::getLayoutSize()
|
||||
{
|
||||
Widget* parent = getWidgetParent();
|
||||
|
@ -214,7 +214,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
}
|
||||
case Direction::HORIZONTAL:
|
||||
{
|
||||
if (_innerContainer->getRightInParent() <= _size.width)
|
||||
if (_innerContainer->getRightBoundary() <= _size.width)
|
||||
{
|
||||
Size newInnerSize = _innerContainer->getSize();
|
||||
float offset = originalInnerSize.width - newInnerSize.width;
|
||||
|
@ -227,7 +227,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
Size newInnerSize = _innerContainer->getSize();
|
||||
float offsetY = originalInnerSize.height - newInnerSize.height;
|
||||
float offsetX = 0.0f;
|
||||
if (_innerContainer->getRightInParent() <= _size.width)
|
||||
if (_innerContainer->getRightBoundary() <= _size.width)
|
||||
{
|
||||
offsetX = originalInnerSize.width - newInnerSize.width;
|
||||
}
|
||||
|
@ -237,11 +237,11 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
default:
|
||||
break;
|
||||
}
|
||||
if (_innerContainer->getLeftInParent() > 0.0f)
|
||||
if (_innerContainer->getLeftBoundary() > 0.0f)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getAnchorPoint().x * _innerContainer->getSize().width, _innerContainer->getPosition().y));
|
||||
}
|
||||
if (_innerContainer->getRightInParent() < _size.width)
|
||||
if (_innerContainer->getRightBoundary() < _size.width)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_size.width - ((1.0f - _innerContainer->getAnchorPoint().x) * _innerContainer->getSize().width), _innerContainer->getPosition().y));
|
||||
}
|
||||
|
@ -249,7 +249,7 @@ void ScrollView::setInnerContainerSize(const Size &size)
|
|||
{
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _innerContainer->getAnchorPoint().y * _innerContainer->getSize().height));
|
||||
}
|
||||
if (_innerContainer->getTopInParent() < _size.height)
|
||||
if (_innerContainer->getTopBoundary() < _size.height)
|
||||
{
|
||||
_innerContainer->setPosition(Vec2(_innerContainer->getPosition().x, _size.height - (1.0f - _innerContainer->getAnchorPoint().y) * _innerContainer->getSize().height));
|
||||
}
|
||||
|
@ -394,56 +394,56 @@ bool ScrollView::checkNeedBounce()
|
|||
{
|
||||
if (_topBounceNeeded && _leftBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(_innerContainer->getLeftInParent(), _innerContainer->getTopInParent());
|
||||
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(_innerContainer->getLeftBoundary(), _innerContainer->getTopBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_topBounceNeeded && _rightBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(_size.width, _size.height) - Vec2(_innerContainer->getRightInParent(), _innerContainer->getTopInParent());
|
||||
Vec2 scrollVector = Vec2(_size.width, _size.height) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getTopBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_bottomBounceNeeded && _leftBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2::ZERO - Vec2(_innerContainer->getLeftInParent(), _innerContainer->getBottomInParent());
|
||||
Vec2 scrollVector = Vec2::ZERO - Vec2(_innerContainer->getLeftBoundary(), _innerContainer->getBottomBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_bottomBounceNeeded && _rightBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightInParent(), _innerContainer->getBottomInParent());
|
||||
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), _innerContainer->getBottomBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_topBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(0.0f, _innerContainer->getTopInParent());
|
||||
Vec2 scrollVector = Vec2(0.0f, _size.height) - Vec2(0.0f, _innerContainer->getTopBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_bottomBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2::ZERO - Vec2(0.0f, _innerContainer->getBottomInParent());
|
||||
Vec2 scrollVector = Vec2::ZERO - Vec2(0.0f, _innerContainer->getBottomBoundary());
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_leftBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2::ZERO - Vec2(_innerContainer->getLeftInParent(), 0.0f);
|
||||
Vec2 scrollVector = Vec2::ZERO - Vec2(_innerContainer->getLeftBoundary(), 0.0f);
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
}
|
||||
else if (_rightBounceNeeded)
|
||||
{
|
||||
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightInParent(), 0.0f);
|
||||
Vec2 scrollVector = Vec2(_size.width, 0.0f) - Vec2(_innerContainer->getRightBoundary(), 0.0f);
|
||||
float orSpeed = scrollVector.getLength()/(0.2f);
|
||||
_bounceDir = scrollVector.getNormalized();
|
||||
startBounceChildren(orSpeed);
|
||||
|
@ -455,7 +455,7 @@ bool ScrollView::checkNeedBounce()
|
|||
|
||||
void ScrollView::checkBounceBoundary()
|
||||
{
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos > _bottomBoundary)
|
||||
{
|
||||
scrollToBottomEvent();
|
||||
|
@ -465,7 +465,7 @@ void ScrollView::checkBounceBoundary()
|
|||
{
|
||||
_bottomBounceNeeded = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos < _topBoundary)
|
||||
{
|
||||
scrollToTopEvent();
|
||||
|
@ -475,7 +475,7 @@ void ScrollView::checkBounceBoundary()
|
|||
{
|
||||
_topBounceNeeded = false;
|
||||
}
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos < _rightBoundary)
|
||||
{
|
||||
scrollToRightEvent();
|
||||
|
@ -485,7 +485,7 @@ void ScrollView::checkBounceBoundary()
|
|||
{
|
||||
_rightBounceNeeded = false;
|
||||
}
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos > _leftBoundary)
|
||||
{
|
||||
scrollToLeftEvent();
|
||||
|
@ -592,14 +592,14 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
{
|
||||
float realOffsetX = touchOffsetX;
|
||||
float realOffsetY = touchOffsetY;
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + realOffsetX >= _rightBoundary)
|
||||
{
|
||||
realOffsetX = _rightBoundary - icRightPos;
|
||||
bounceRightEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY >= _topBoundary)
|
||||
{
|
||||
realOffsetY = _topBoundary - icTopPos;
|
||||
|
@ -612,14 +612,14 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
{
|
||||
float realOffsetX = touchOffsetX;
|
||||
float realOffsetY = touchOffsetY;
|
||||
float icLefrPos = _innerContainer->getLeftInParent();
|
||||
float icLefrPos = _innerContainer->getLeftBoundary();
|
||||
if (icLefrPos + realOffsetX <= _leftBoundary)
|
||||
{
|
||||
realOffsetX = _leftBoundary - icLefrPos;
|
||||
bounceLeftEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY >= _topBoundary)
|
||||
{
|
||||
realOffsetY = _topBoundary - icTopPos;
|
||||
|
@ -632,14 +632,14 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
{
|
||||
float realOffsetX = touchOffsetX;
|
||||
float realOffsetY = touchOffsetY;
|
||||
float icLefrPos = _innerContainer->getLeftInParent();
|
||||
float icLefrPos = _innerContainer->getLeftBoundary();
|
||||
if (icLefrPos + realOffsetX <= _leftBoundary)
|
||||
{
|
||||
realOffsetX = _leftBoundary - icLefrPos;
|
||||
bounceLeftEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY <= _bottomBoundary)
|
||||
{
|
||||
realOffsetY = _bottomBoundary - icBottomPos;
|
||||
|
@ -652,14 +652,14 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
{
|
||||
float realOffsetX = touchOffsetX;
|
||||
float realOffsetY = touchOffsetY;
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + realOffsetX >= _rightBoundary)
|
||||
{
|
||||
realOffsetX = _rightBoundary - icRightPos;
|
||||
bounceRightEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY <= _bottomBoundary)
|
||||
{
|
||||
realOffsetY = _bottomBoundary - icBottomPos;
|
||||
|
@ -671,7 +671,7 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
else if (touchOffsetX == 0.0f && touchOffsetY > 0.0f) // bounce to top
|
||||
{
|
||||
float realOffsetY = touchOffsetY;
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY >= _topBoundary)
|
||||
{
|
||||
realOffsetY = _topBoundary - icTopPos;
|
||||
|
@ -683,7 +683,7 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
else if (touchOffsetX == 0.0f && touchOffsetY < 0.0f) //bounce to bottom
|
||||
{
|
||||
float realOffsetY = touchOffsetY;
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY <= _bottomBoundary)
|
||||
{
|
||||
realOffsetY = _bottomBoundary - icBottomPos;
|
||||
|
@ -695,7 +695,7 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
else if (touchOffsetX > 0.0f && touchOffsetY == 0.0f) //bounce to right
|
||||
{
|
||||
float realOffsetX = touchOffsetX;
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + realOffsetX >= _rightBoundary)
|
||||
{
|
||||
realOffsetX = _rightBoundary - icRightPos;
|
||||
|
@ -707,7 +707,7 @@ bool ScrollView::bounceScrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
else if (touchOffsetX < 0.0f && touchOffsetY == 0.0f) //bounce to left
|
||||
{
|
||||
float realOffsetX = touchOffsetX;
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + realOffsetX <= _leftBoundary)
|
||||
{
|
||||
realOffsetX = _leftBoundary - icLeftPos;
|
||||
|
@ -728,7 +728,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
{
|
||||
if (_autoScrollDir.y > 0)
|
||||
{
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icBottomPos;
|
||||
|
@ -737,7 +737,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else
|
||||
{
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + *touchOffsetY <= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icBottomPos;
|
||||
|
@ -750,7 +750,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
{
|
||||
if (_autoScrollDir.x > 0)
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icLeftPos;
|
||||
|
@ -759,7 +759,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + *touchOffsetX <= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icLeftPos;
|
||||
|
@ -772,13 +772,13 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
{
|
||||
if (*touchOffsetX > 0.0f && *touchOffsetY > 0.0f) // up right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icLeftPos;
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icBottomPos;
|
||||
|
@ -787,13 +787,13 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX < 0.0f && *touchOffsetY > 0.0f) // up left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + *touchOffsetX <= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icRightPos;
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icBottomPos;
|
||||
|
@ -802,13 +802,13 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX < 0.0f && *touchOffsetY < 0.0f) // down left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + *touchOffsetX <= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icRightPos;
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + *touchOffsetY <= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icTopPos;
|
||||
|
@ -817,13 +817,13 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX > 0.0f && *touchOffsetY < 0.0f) // down right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icLeftPos;
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + *touchOffsetY <= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icTopPos;
|
||||
|
@ -832,7 +832,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX == 0.0f && *touchOffsetY > 0.0f) // up
|
||||
{
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + *touchOffsetY >= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icBottomPos;
|
||||
|
@ -841,7 +841,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX < 0.0f && *touchOffsetY == 0.0f) // left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + *touchOffsetX <= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icRightPos;
|
||||
|
@ -850,7 +850,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX == 0.0f && *touchOffsetY < 0.0f) // down
|
||||
{
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + *touchOffsetY <= _autoScrollDestination.y)
|
||||
{
|
||||
*touchOffsetY = _autoScrollDestination.y - icTopPos;
|
||||
|
@ -859,7 +859,7 @@ bool ScrollView::checkCustomScrollDestination(float* touchOffsetX, float* touchO
|
|||
}
|
||||
else if (*touchOffsetX > 0.0f && *touchOffsetY == 0.0f) // right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + *touchOffsetX >= _autoScrollDestination.x)
|
||||
{
|
||||
*touchOffsetX = _autoScrollDestination.x - icLeftPos;
|
||||
|
@ -893,6 +893,7 @@ bool ScrollView::scrollChildrenVertical(float touchOffsetX, float touchOffsetY)
|
|||
realOffset = _bounceTopBoundary - icTopPos;
|
||||
scrollToTopEvent();
|
||||
scrollEnabled = false;
|
||||
|
||||
}
|
||||
}
|
||||
else
|
||||
|
@ -968,13 +969,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
if (touchOffsetX > 0.0f && touchOffsetY > 0.0f) // up right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
|
||||
if (icLeftPos + touchOffsetX >= _bounceLeftBoundary)
|
||||
{
|
||||
realOffsetX = _bounceLeftBoundary - icLeftPos;
|
||||
scrollToLeftEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
|
||||
if (icBottomPos + touchOffsetY >= _bounceBottomBoundary)
|
||||
{
|
||||
realOffsetY = _bounceBottomBoundary - icBottomPos;
|
||||
|
@ -984,14 +988,17 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX < 0.0f && touchOffsetY > 0.0f) // up left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
|
||||
if (icRightPos + touchOffsetX <= _bounceRightBoundary)
|
||||
{
|
||||
realOffsetX = _bounceRightBoundary - icRightPos;
|
||||
scrollToRightEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY >= _bounceBottomBoundary)
|
||||
{
|
||||
realOffsetY = _bounceBottomBoundary - icBottomPos;
|
||||
|
@ -1001,14 +1008,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX < 0.0f && touchOffsetY < 0.0f) // down left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + touchOffsetX <= _bounceRightBoundary)
|
||||
{
|
||||
realOffsetX = _bounceRightBoundary - icRightPos;
|
||||
scrollToRightEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY <= _bounceTopBoundary)
|
||||
{
|
||||
realOffsetY = _bounceTopBoundary - icTopPos;
|
||||
|
@ -1018,14 +1027,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX > 0.0f && touchOffsetY < 0.0f) // down right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + touchOffsetX >= _bounceLeftBoundary)
|
||||
{
|
||||
realOffsetX = _bounceLeftBoundary - icLeftPos;
|
||||
scrollToLeftEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY <= _bounceTopBoundary)
|
||||
{
|
||||
realOffsetY = _bounceTopBoundary - icTopPos;
|
||||
|
@ -1035,7 +1046,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX == 0.0f && touchOffsetY > 0.0f) // up
|
||||
{
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY >= _bounceBottomBoundary)
|
||||
{
|
||||
realOffsetY = _bounceBottomBoundary - icBottomPos;
|
||||
|
@ -1045,7 +1057,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX < 0.0f && touchOffsetY == 0.0f) // left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + touchOffsetX <= _bounceRightBoundary)
|
||||
{
|
||||
realOffsetX = _bounceRightBoundary - icRightPos;
|
||||
|
@ -1055,7 +1068,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX == 0.0f && touchOffsetY < 0.0f) // down
|
||||
{
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY <= _bounceTopBoundary)
|
||||
{
|
||||
realOffsetY = _bounceTopBoundary - icTopPos;
|
||||
|
@ -1065,7 +1079,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX > 0.0f && touchOffsetY == 0.0f) // right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + touchOffsetX >= _bounceLeftBoundary)
|
||||
{
|
||||
realOffsetX = _bounceLeftBoundary - icLeftPos;
|
||||
|
@ -1078,14 +1093,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
{
|
||||
if (touchOffsetX > 0.0f && touchOffsetY > 0.0f) // up right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + touchOffsetX >= _leftBoundary)
|
||||
{
|
||||
realOffsetX = _leftBoundary - icLeftPos;
|
||||
scrollToLeftEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY >= _bottomBoundary)
|
||||
{
|
||||
realOffsetY = _bottomBoundary - icBottomPos;
|
||||
|
@ -1095,14 +1112,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX < 0.0f && touchOffsetY > 0.0f) // up left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + touchOffsetX <= _rightBoundary)
|
||||
{
|
||||
realOffsetX = _rightBoundary - icRightPos;
|
||||
scrollToRightEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY >= _bottomBoundary)
|
||||
{
|
||||
realOffsetY = _bottomBoundary - icBottomPos;
|
||||
|
@ -1112,14 +1131,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX < 0.0f && touchOffsetY < 0.0f) // down left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + touchOffsetX <= _rightBoundary)
|
||||
{
|
||||
realOffsetX = _rightBoundary - icRightPos;
|
||||
scrollToRightEvent();
|
||||
scrollenabled = false;
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY <= _topBoundary)
|
||||
{
|
||||
realOffsetY = _topBoundary - icTopPos;
|
||||
|
@ -1129,14 +1150,16 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX > 0.0f && touchOffsetY < 0.0f) // down right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + touchOffsetX >= _leftBoundary)
|
||||
{
|
||||
realOffsetX = _leftBoundary - icLeftPos;
|
||||
scrollToLeftEvent();
|
||||
scrollenabled = false;
|
||||
|
||||
}
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY <= _topBoundary)
|
||||
{
|
||||
realOffsetY = _topBoundary - icTopPos;
|
||||
|
@ -1146,7 +1169,7 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX == 0.0f && touchOffsetY > 0.0f) // up
|
||||
{
|
||||
float icBottomPos = _innerContainer->getBottomInParent();
|
||||
float icBottomPos = _innerContainer->getBottomBoundary();
|
||||
if (icBottomPos + touchOffsetY >= _bottomBoundary)
|
||||
{
|
||||
realOffsetY = _bottomBoundary - icBottomPos;
|
||||
|
@ -1156,7 +1179,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX < 0.0f && touchOffsetY == 0.0f) // left
|
||||
{
|
||||
float icRightPos = _innerContainer->getRightInParent();
|
||||
|
||||
float icRightPos = _innerContainer->getRightBoundary();
|
||||
if (icRightPos + touchOffsetX <= _rightBoundary)
|
||||
{
|
||||
realOffsetX = _rightBoundary - icRightPos;
|
||||
|
@ -1166,7 +1190,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX == 0.0f && touchOffsetY < 0.0f) // down
|
||||
{
|
||||
float icTopPos = _innerContainer->getTopInParent();
|
||||
|
||||
float icTopPos = _innerContainer->getTopBoundary();
|
||||
if (icTopPos + touchOffsetY <= _topBoundary)
|
||||
{
|
||||
realOffsetY = _topBoundary - icTopPos;
|
||||
|
@ -1176,7 +1201,8 @@ bool ScrollView::scrollChildrenBoth(float touchOffsetX, float touchOffsetY)
|
|||
}
|
||||
else if (touchOffsetX > 0.0f && touchOffsetY == 0.0f) // right
|
||||
{
|
||||
float icLeftPos = _innerContainer->getLeftInParent();
|
||||
|
||||
float icLeftPos = _innerContainer->getLeftBoundary();
|
||||
if (icLeftPos + touchOffsetX >= _leftBoundary)
|
||||
{
|
||||
realOffsetX = _leftBoundary - icLeftPos;
|
||||
|
@ -1193,6 +1219,7 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
{
|
||||
bool scrollenabled = true;
|
||||
scrollingEvent();
|
||||
|
||||
switch (_direction)
|
||||
{
|
||||
case Direction::VERTICAL: // vertical
|
||||
|
@ -1203,11 +1230,13 @@ bool ScrollView::scrollChildren(float touchOffsetX, float touchOffsetY)
|
|||
case Direction::HORIZONTAL: // horizontal
|
||||
{
|
||||
scrollenabled = scrollChildrenHorizontal(touchOffsetX, touchOffsetY);
|
||||
|
||||
break;
|
||||
}
|
||||
case Direction::BOTH:
|
||||
{
|
||||
scrollenabled = scrollChildrenBoth(touchOffsetX, touchOffsetY);
|
||||
|
||||
break;
|
||||
}
|
||||
default:
|
||||
|
@ -1761,6 +1790,9 @@ void ScrollView::copySpecialProperties(Widget *widget)
|
|||
setDirection(scrollView->_direction);
|
||||
setBounceEnabled(scrollView->_bounceEnabled);
|
||||
setInertiaScrollEnabled(scrollView->_inertiaScrollEnabled);
|
||||
_scrollViewEventListener = scrollView->_scrollViewEventListener;
|
||||
_scrollViewEventSelector = scrollView->_scrollViewEventSelector;
|
||||
_eventCallback = scrollView->_eventCallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -355,10 +355,11 @@ protected:
|
|||
bool checkCustomScrollDestination(float* touchOffsetX, float* touchOffsetY);
|
||||
|
||||
virtual bool scrollChildren(float touchOffsetX, float touchOffsetY);
|
||||
|
||||
bool scrollChildrenVertical(float touchOffsetX, float touchOffsetY);
|
||||
bool scrollChildrenHorizontal(float touchOffsetX, float touchOffestY);
|
||||
bool scrollChildrenBoth(float touchOffsetX, float touchOffsetY);
|
||||
|
||||
|
||||
|
||||
bool bounceScrollChildren(float touchOffsetX, float touchOffsetY);
|
||||
void startRecordSlidAction();
|
||||
|
|
|
@ -627,6 +627,9 @@ void Slider::copySpecialProperties(Widget *widget)
|
|||
loadSlidBallTexturePressed(slider->_slidBallPressedTextureFile, slider->_ballPTexType);
|
||||
loadSlidBallTextureDisabled(slider->_slidBallDisabledTextureFile, slider->_ballDTexType);
|
||||
setPercent(slider->getPercent());
|
||||
_sliderEventListener = slider->_sliderEventListener;
|
||||
_sliderEventSelector = slider->_sliderEventSelector;
|
||||
_eventCallback = slider->_eventCallback;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -842,6 +842,9 @@ void TextField::copySpecialProperties(Widget *widget)
|
|||
setDetachWithIME(textField->getDetachWithIME());
|
||||
setInsertText(textField->getInsertText());
|
||||
setDeleteBackward(textField->getDeleteBackward());
|
||||
_eventCallback = textField->_eventCallback;
|
||||
_textFieldEventListener = textField->_textFieldEventListener;
|
||||
_textFieldEventSelector = textField->_textFieldEventSelector;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -77,6 +77,9 @@ namespace experimental{
|
|||
virtual void draw(Renderer *renderer, const Mat4& transform, bool transformUpdated) override;
|
||||
|
||||
protected:
|
||||
virtual cocos2d::ui::Widget* createCloneInstance() override;
|
||||
virtual void copySpecialProperties(Widget* model) override;
|
||||
|
||||
VideoPlayer();
|
||||
virtual ~VideoPlayer();
|
||||
|
||||
|
|
|
@ -355,6 +355,28 @@ void VideoPlayer::onPlayEvent(VideoPlayer::EventType event)
|
|||
}
|
||||
}
|
||||
|
||||
cocos2d::ui::Widget* VideoPlayer::createCloneInstance()
|
||||
{
|
||||
return VideoPlayer::create();
|
||||
}
|
||||
|
||||
void VideoPlayer::copySpecialProperties(Widget *widget)
|
||||
{
|
||||
VideoPlayer* videoPlayer = dynamic_cast<VideoPlayer*>(widget);
|
||||
if (videoPlayer)
|
||||
{
|
||||
_isPlaying = videoPlayer->_isPlaying;
|
||||
_fullScreenEnabled = videoPlayer->_fullScreenEnabled;
|
||||
_fullScreenDirty = videoPlayer->_fullScreenDirty;
|
||||
_videoURL = videoPlayer->_videoURL;
|
||||
_keepAspectRatioEnabled = videoPlayer->_keepAspectRatioEnabled;
|
||||
_videoSource = videoPlayer->_videoSource;
|
||||
_videoPlayerIndex = videoPlayer->_videoPlayerIndex;
|
||||
_eventCallback = videoPlayer->_eventCallback;
|
||||
_videoView = videoPlayer->_videoView;
|
||||
}
|
||||
}
|
||||
|
||||
void executeVideoCallback(int index,int event)
|
||||
{
|
||||
auto it = s_allVideoPlayers.find(index);
|
||||
|
|
|
@ -461,4 +461,26 @@ void VideoPlayer::onPlayEvent(VideoPlayer::EventType event)
|
|||
}
|
||||
}
|
||||
|
||||
cocos2d::ui::Widget* VideoPlayer::createCloneInstance()
|
||||
{
|
||||
return VideoPlayer::create();
|
||||
}
|
||||
|
||||
void VideoPlayer::copySpecialProperties(Widget *widget)
|
||||
{
|
||||
VideoPlayer* videoPlayer = dynamic_cast<VideoPlayer*>(widget);
|
||||
if (videoPlayer)
|
||||
{
|
||||
_isPlaying = videoPlayer->_isPlaying;
|
||||
_fullScreenEnabled = videoPlayer->_fullScreenEnabled;
|
||||
_fullScreenDirty = videoPlayer->_fullScreenDirty;
|
||||
_videoURL = videoPlayer->_videoURL;
|
||||
_keepAspectRatioEnabled = videoPlayer->_keepAspectRatioEnabled;
|
||||
_videoSource = videoPlayer->_videoSource;
|
||||
_videoPlayerIndex = videoPlayer->_videoPlayerIndex;
|
||||
_eventCallback = videoPlayer->_eventCallback;
|
||||
_videoView = videoPlayer->_videoView;
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
@ -63,7 +63,8 @@ _opacity(255),
|
|||
_flippedX(false),
|
||||
_flippedY(false),
|
||||
_focused(false),
|
||||
_focusEnabled(true)
|
||||
_focusEnabled(true),
|
||||
_layoutParameterType(LayoutParameter::Type::NONE)
|
||||
{
|
||||
onFocusChanged = CC_CALLBACK_2(Widget::onFocusChange,this);
|
||||
onNextFocusedWidget = nullptr;
|
||||
|
@ -817,24 +818,24 @@ bool Widget::isEnabled() const
|
|||
return _enabled;
|
||||
}
|
||||
|
||||
float Widget::getLeftInParent()
|
||||
float Widget::getLeftBoundary() const
|
||||
{
|
||||
return getPosition().x - getAnchorPoint().x * _size.width;;
|
||||
return getPosition().x - getAnchorPoint().x * _size.width;
|
||||
}
|
||||
|
||||
float Widget::getBottomInParent()
|
||||
float Widget::getBottomBoundary() const
|
||||
{
|
||||
return getPosition().y - getAnchorPoint().y * _size.height;;
|
||||
return getPosition().y - getAnchorPoint().y * _size.height;
|
||||
}
|
||||
|
||||
float Widget::getRightInParent()
|
||||
float Widget::getRightBoundary() const
|
||||
{
|
||||
return getLeftInParent() + _size.width;
|
||||
return getLeftBoundary() + _size.width;
|
||||
}
|
||||
|
||||
float Widget::getTopInParent()
|
||||
float Widget::getTopBoundary() const
|
||||
{
|
||||
return getBottomInParent() + _size.height;
|
||||
return getBottomBoundary() + _size.height;
|
||||
}
|
||||
|
||||
const Vec2& Widget::getTouchStartPos()
|
||||
|
@ -870,8 +871,14 @@ void Widget::setLayoutParameter(LayoutParameter *parameter)
|
|||
return;
|
||||
}
|
||||
_layoutParameterDictionary.insert((int)parameter->getLayoutType(), parameter);
|
||||
_layoutParameterType = parameter->getLayoutType();
|
||||
}
|
||||
|
||||
LayoutParameter* Widget::getLayoutParameter()
|
||||
{
|
||||
return dynamic_cast<LayoutParameter*>(_layoutParameterDictionary.at((int)_layoutParameterType));
|
||||
}
|
||||
|
||||
LayoutParameter* Widget::getLayoutParameter(LayoutParameter::Type type)
|
||||
{
|
||||
return dynamic_cast<LayoutParameter*>(_layoutParameterDictionary.at((int)type));
|
||||
|
@ -927,7 +934,6 @@ void Widget::copyProperties(Widget *widget)
|
|||
_ignoreSize = widget->_ignoreSize;
|
||||
_size = widget->_size;
|
||||
_customSize = widget->_customSize;
|
||||
copySpecialProperties(widget);
|
||||
_sizeType = widget->getSizeType();
|
||||
_sizePercent = widget->_sizePercent;
|
||||
_positionType = widget->_positionType;
|
||||
|
@ -943,6 +949,14 @@ void Widget::copyProperties(Widget *widget)
|
|||
setFlippedY(widget->isFlippedY());
|
||||
setColor(widget->getColor());
|
||||
setOpacity(widget->getOpacity());
|
||||
_touchEventCallback = widget->_touchEventCallback;
|
||||
_touchEventListener = widget->_touchEventListener;
|
||||
_touchEventSelector = widget->_touchEventSelector;
|
||||
_focused = widget->_focused;
|
||||
_focusEnabled = widget->_focusEnabled;
|
||||
|
||||
copySpecialProperties(widget);
|
||||
|
||||
//FIXME:copy focus properties, also make sure all the subclass the copy behavior is correct
|
||||
Map<int, LayoutParameter*>& layoutParameterDic = widget->_layoutParameterDictionary;
|
||||
for (auto iter = layoutParameterDic.begin(); iter != layoutParameterDic.end(); ++iter)
|
||||
|
|
|
@ -28,6 +28,7 @@ THE SOFTWARE.
|
|||
#include "ui/CCProtectedNode.h"
|
||||
#include "ui/UILayoutParameter.h"
|
||||
#include "ui/GUIDefine.h"
|
||||
#include "ui/UILayoutParameter.h"
|
||||
|
||||
NS_CC_BEGIN
|
||||
|
||||
|
@ -57,7 +58,7 @@ CC_DEPRECATED_ATTRIBUTE typedef void (Ref::*SEL_TouchEvent)(Ref*,TouchEventType)
|
|||
#endif
|
||||
|
||||
|
||||
class Widget : public ProtectedNode
|
||||
class Widget : public ProtectedNode, public LayoutParameterProtocol
|
||||
{
|
||||
public:
|
||||
enum class FocusDirection
|
||||
|
@ -200,28 +201,32 @@ public:
|
|||
*
|
||||
* @return The left boundary position of this widget.
|
||||
*/
|
||||
float getLeftInParent();
|
||||
CC_DEPRECATED_ATTRIBUTE float getLeftInParent(){return this->getLeftBoundary();}
|
||||
float getLeftBoundary() const;
|
||||
|
||||
/**
|
||||
* Gets the bottom boundary position of this widget.
|
||||
*
|
||||
* @return The bottom boundary position of this widget.
|
||||
*/
|
||||
float getBottomInParent();
|
||||
CC_DEPRECATED_ATTRIBUTE float getBottomInParent(){return this->getBottomBoundary();}
|
||||
float getBottomBoundary() const;
|
||||
|
||||
/**
|
||||
* Gets the right boundary position of this widget.
|
||||
*
|
||||
* @return The right boundary position of this widget.
|
||||
*/
|
||||
float getRightInParent();
|
||||
CC_DEPRECATED_ATTRIBUTE float getRightInParent(){return this->getRightBoundary();}
|
||||
float getRightBoundary() const;
|
||||
|
||||
/**
|
||||
* Gets the top boundary position of this widget.
|
||||
*
|
||||
* @return The top boundary position of this widget.
|
||||
*/
|
||||
float getTopInParent();
|
||||
CC_DEPRECATED_ATTRIBUTE float getTopInParent(){return this->getTopBoundary();}
|
||||
float getTopBoundary() const;
|
||||
|
||||
/**
|
||||
* Gets a child from the container with its name
|
||||
|
@ -482,7 +487,9 @@ public:
|
|||
*
|
||||
* @return LayoutParameter
|
||||
*/
|
||||
LayoutParameter* getLayoutParameter(LayoutParameter::Type type);
|
||||
LayoutParameter* getLayoutParameter() override;
|
||||
CC_DEPRECATED_ATTRIBUTE LayoutParameter* getLayoutParameter(LayoutParameter::Type type);
|
||||
|
||||
|
||||
/**
|
||||
* Ignore the widget size
|
||||
|
@ -676,9 +683,12 @@ protected:
|
|||
Size _size;
|
||||
Size _customSize;
|
||||
bool _ignoreSize;
|
||||
bool _affectByClipping;
|
||||
|
||||
SizeType _sizeType;
|
||||
Vec2 _sizePercent;
|
||||
|
||||
bool _affectByClipping;
|
||||
|
||||
PositionType _positionType;
|
||||
Vec2 _positionPercent;
|
||||
bool _reorderWidgetChildDirty;
|
||||
|
@ -688,8 +698,10 @@ protected:
|
|||
GLubyte _opacity;
|
||||
bool _flippedX;
|
||||
bool _flippedY;
|
||||
Map<int, LayoutParameter*> _layoutParameterDictionary;
|
||||
|
||||
//use map to enble switch back and forth for user layout parameters
|
||||
Map<int,LayoutParameter*> _layoutParameterDictionary;
|
||||
LayoutParameter::Type _layoutParameterType;
|
||||
|
||||
bool _focused;
|
||||
bool _focusEnabled;
|
||||
|
||||
|
|
|
@ -19,6 +19,7 @@
|
|||
<ClInclude Include="..\UIHelper.h" />
|
||||
<ClInclude Include="..\UIImageView.h" />
|
||||
<ClInclude Include="..\UILayout.h" />
|
||||
<ClInclude Include="..\UILayoutExecutant.h" />
|
||||
<ClInclude Include="..\UILayoutParameter.h" />
|
||||
<ClInclude Include="..\UIListView.h" />
|
||||
<ClInclude Include="..\UILoadingBar.h" />
|
||||
|
@ -44,6 +45,7 @@
|
|||
<ClCompile Include="..\UIHelper.cpp" />
|
||||
<ClCompile Include="..\UIImageView.cpp" />
|
||||
<ClCompile Include="..\UILayout.cpp" />
|
||||
<ClCompile Include="..\UILayoutExecutant.cpp" />
|
||||
<ClCompile Include="..\UILayoutParameter.cpp" />
|
||||
<ClCompile Include="..\UIListView.cpp" />
|
||||
<ClCompile Include="..\UILoadingBar.cpp" />
|
||||
|
|
|
@ -87,6 +87,9 @@
|
|||
<ClInclude Include="..\UIVBox.h">
|
||||
<Filter>Layouts</Filter>
|
||||
</ClInclude>
|
||||
<ClInclude Include="..\UILayoutExecutant.h">
|
||||
<Filter>Layouts</Filter>
|
||||
</ClInclude>
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<ClCompile Include="..\UIScrollView.cpp">
|
||||
|
@ -155,5 +158,8 @@
|
|||
<ClCompile Include="..\UIVBox.cpp">
|
||||
<Filter>Layouts</Filter>
|
||||
</ClCompile>
|
||||
<ClCompile Include="..\UILayoutExecutant.cpp">
|
||||
<Filter>Layouts</Filter>
|
||||
</ClCompile>
|
||||
</ItemGroup>
|
||||
</Project>
|
|
@ -24,6 +24,7 @@ using Microsoft.Phone.Shell;
|
|||
using Windows.UI.Input;
|
||||
using System.Windows.Threading;
|
||||
using Microsoft.Phone.Info;
|
||||
using Windows.Graphics.Display;
|
||||
|
||||
namespace PhoneDirect3DXamlAppInterop
|
||||
{
|
||||
|
@ -53,7 +54,30 @@ namespace PhoneDirect3DXamlAppInterop
|
|||
{
|
||||
if (m_d3dInterop == null)
|
||||
{
|
||||
m_d3dInterop = new Direct3DInterop();
|
||||
PageOrientation pageOrientation = (PageOrientation)GetValue(OrientationProperty);
|
||||
DisplayOrientations displayOrientation;
|
||||
|
||||
switch(pageOrientation)
|
||||
{
|
||||
case PageOrientation.Portrait:
|
||||
case PageOrientation.PortraitUp:
|
||||
displayOrientation = DisplayOrientations.Portrait;
|
||||
break;
|
||||
case PageOrientation.PortraitDown:
|
||||
displayOrientation = DisplayOrientations.PortraitFlipped;
|
||||
break;
|
||||
case PageOrientation.Landscape:
|
||||
case PageOrientation.LandscapeLeft:
|
||||
displayOrientation = DisplayOrientations.Landscape;
|
||||
break;
|
||||
case PageOrientation.LandscapeRight:
|
||||
displayOrientation = DisplayOrientations.LandscapeFlipped;
|
||||
break;
|
||||
default:
|
||||
displayOrientation = DisplayOrientations.Landscape;
|
||||
break;
|
||||
}
|
||||
m_d3dInterop = new Direct3DInterop(displayOrientation);
|
||||
|
||||
// Set WindowBounds to size of DrawingSurface
|
||||
m_d3dInterop.WindowBounds = new Windows.Foundation.Size(
|
||||
|
|
|
@ -40,6 +40,21 @@
|
|||
"*.lua"
|
||||
]
|
||||
},
|
||||
{
|
||||
"from": "templates/lua-template-runtime/runtime/rtres",
|
||||
"to": "runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources/rtres",
|
||||
"exclude": []
|
||||
},
|
||||
{
|
||||
"from": "templates/lua-template-runtime/runtime/rtres",
|
||||
"to": "runtime/ios/PrebuiltRuntimeLua.app/rtres",
|
||||
"exclude": []
|
||||
},
|
||||
{
|
||||
"from": "templates/lua-template-runtime/runtime/rtres",
|
||||
"to": "runtime/win32/rtres",
|
||||
"exclude": []
|
||||
},
|
||||
{
|
||||
"from": "cocos/scripting/lua-bindings/script",
|
||||
"to": "runtime/mac/PrebuiltRuntimeLua.app/Contents/Resources",
|
||||
|
|
|
@ -51,6 +51,13 @@ void ConfigParser::readConfig()
|
|||
{
|
||||
_initViewSize.width = objectInitView["width"].GetUint();
|
||||
_initViewSize.height = objectInitView["height"].GetUint();
|
||||
if (_initViewSize.height>_initViewSize.width)
|
||||
{
|
||||
float tmpvalue =_initViewSize.height;
|
||||
_initViewSize.height = _initViewSize.width;
|
||||
_initViewSize.width = tmpvalue;
|
||||
}
|
||||
|
||||
}
|
||||
if (objectInitView.HasMember("name") && objectInitView["name"].IsString())
|
||||
{
|
||||
|
|
|
@ -99,50 +99,114 @@ bool reloadScript(const string& modulefile)
|
|||
class ConnectWaitLayer: public Layer
|
||||
{
|
||||
private:
|
||||
LabelTTF* pLabelUploadFile;
|
||||
Label* _labelUploadFile;
|
||||
public:
|
||||
|
||||
ConnectWaitLayer()
|
||||
{
|
||||
int designWidth = 1280;
|
||||
int designHeight = 800;
|
||||
Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designWidth,designHeight,ResolutionPolicy::EXACT_FIT);
|
||||
string playEnbleFile = "rtres/Play1.png";
|
||||
string shineFile = "rtres/shine.png";
|
||||
string backgroundFile = "rtres/landscape.png";
|
||||
if (!ConfigParser::getInstance()->isLanscape())
|
||||
{
|
||||
backgroundFile = "rtres/portrait.png";
|
||||
Director::getInstance()->getOpenGLView()->setDesignResolutionSize(designHeight,designWidth,ResolutionPolicy::EXACT_FIT);
|
||||
}
|
||||
|
||||
auto background = Sprite::create(backgroundFile.c_str());
|
||||
if (background)
|
||||
{
|
||||
background->setAnchorPoint(Vec2(0,0));
|
||||
addChild(background,9999);
|
||||
}
|
||||
|
||||
auto playSprite = Sprite::create(playEnbleFile.c_str());
|
||||
if (playSprite)
|
||||
{
|
||||
playSprite->setPosition(Vec2(902,400));
|
||||
addChild(playSprite,9999);
|
||||
}else
|
||||
{
|
||||
auto labelPlay = LabelTTF::create("play", "Arial", 108);
|
||||
auto menuItem = MenuItemLabel::create(labelPlay, CC_CALLBACK_1(ConnectWaitLayer::playerCallback, this));
|
||||
auto menu = Menu::create(menuItem, NULL);
|
||||
|
||||
menu->setPosition( Point::ZERO );
|
||||
menuItem->setPosition(Vec2(902,400));
|
||||
if (!ConfigParser::getInstance()->isLanscape()) menuItem->setPosition(Vec2(400,500));
|
||||
addChild(menu, 1);
|
||||
}
|
||||
|
||||
auto shineSprite = Sprite::create(shineFile.c_str());
|
||||
if (shineSprite)
|
||||
{
|
||||
shineSprite->setPosition(Vec2(902,400));
|
||||
shineSprite->runAction(RepeatForever::create(Sequence::createWithTwoActions(ScaleBy::create(1.0f, 1.08f),ScaleTo::create(1.0f, 1))));
|
||||
addChild(shineSprite,9999);
|
||||
}
|
||||
|
||||
string strip = getIPAddress();
|
||||
char szIPAddress[512]={0};
|
||||
sprintf(szIPAddress, "LocalIP: %s",strip.c_str());
|
||||
auto label = LabelTTF::create(szIPAddress, "Arial", 24);
|
||||
addChild(label, 9999);
|
||||
label->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 30) );
|
||||
|
||||
string strShowMsg ="";
|
||||
sprintf(szIPAddress, "IP: %s",strip.c_str());
|
||||
auto IPlabel = Label::create(szIPAddress, "Arial", 72);
|
||||
IPlabel->setAnchorPoint(Vec2(0,0));
|
||||
int spaceSizex = 72;
|
||||
int spaceSizey = 200;
|
||||
IPlabel->setPosition( Point(VisibleRect::leftTop().x+spaceSizex, VisibleRect::top().y -spaceSizey) );
|
||||
addChild(IPlabel, 9999);
|
||||
|
||||
string strShowMsg = "waiting for file transfer ...";
|
||||
if (CC_PLATFORM_WIN32 == CC_TARGET_PLATFORM || CC_PLATFORM_MAC == CC_TARGET_PLATFORM)
|
||||
{
|
||||
strShowMsg = "waiting for debugger to connect ...";
|
||||
}else
|
||||
}
|
||||
|
||||
_labelUploadFile = Label::create(strShowMsg.c_str(), "Arial", 36);
|
||||
_labelUploadFile->setAnchorPoint(Vec2(0,0));
|
||||
_labelUploadFile->setPosition( Point(VisibleRect::leftTop().x+spaceSizex, IPlabel->getPositionY()-spaceSizex) );
|
||||
_labelUploadFile->setAlignment(TextHAlignment::LEFT);
|
||||
addChild(_labelUploadFile, 10000);
|
||||
|
||||
if (!ConfigParser::getInstance()->isLanscape())
|
||||
{
|
||||
strShowMsg = "waiting for file transfer ...";
|
||||
}
|
||||
auto labelwait = LabelTTF::create(strShowMsg.c_str(), "Arial", 22);
|
||||
addChild(labelwait, 10000);
|
||||
labelwait->setPosition( Point(VisibleRect::center().x, VisibleRect::center().y) );
|
||||
if (playSprite) playSprite->setPosition(400,500);
|
||||
if (shineSprite) shineSprite->setPosition(400,500);
|
||||
_labelUploadFile->setAlignment(TextHAlignment::LEFT);
|
||||
}
|
||||
|
||||
pLabelUploadFile = LabelTTF::create("", "Arial", 22);
|
||||
addChild(pLabelUploadFile, 10000);
|
||||
pLabelUploadFile->setPosition( Point(VisibleRect::center().x, VisibleRect::top().y - 60) );
|
||||
|
||||
auto labelPlay = LabelTTF::create("play", "Arial", 36);
|
||||
auto menuItem = MenuItemLabel::create(labelPlay, CC_CALLBACK_1(ConnectWaitLayer::playerCallback, this));
|
||||
auto menu = Menu::create(menuItem, NULL);
|
||||
if (playSprite)
|
||||
{
|
||||
auto listener = EventListenerTouchOneByOne::create();
|
||||
listener->onTouchBegan = [](Touch* touch, Event *event)->bool{
|
||||
auto target = static_cast<Sprite*>(event->getCurrentTarget());
|
||||
Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
|
||||
auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height);
|
||||
if (!rect.containsPoint(point)) return false;
|
||||
target->stopAllActions();
|
||||
target->runAction(Sequence::createWithTwoActions(ScaleBy::create(0.05f, 0.9f),ScaleTo::create(0.125f, 1)));
|
||||
return true;
|
||||
};
|
||||
listener->onTouchEnded = [](Touch* touch, Event *event){
|
||||
auto target = static_cast<Sprite*>(event->getCurrentTarget());
|
||||
Vec2 point = target->convertToNodeSpace(Director::getInstance()->convertToGL(touch->getLocationInView()));
|
||||
auto rect = Rect(0, 0, target->getContentSize().width, target->getContentSize().height);
|
||||
if (!rect.containsPoint(point)) return;
|
||||
startScript("");
|
||||
};
|
||||
_eventDispatcher->addEventListenerWithSceneGraphPriority(listener, playSprite);
|
||||
}
|
||||
|
||||
menu->setPosition( Point::ZERO );
|
||||
menuItem->setPosition( Point( VisibleRect::right().x - 50, VisibleRect::bottom().y + 25) );
|
||||
addChild(menu, 1);
|
||||
}
|
||||
|
||||
|
||||
void playerCallback(Object* sender)
|
||||
{
|
||||
startScript("");
|
||||
}
|
||||
|
||||
void showCurRcvFile(string fileName) {
|
||||
pLabelUploadFile->setString(fileName);
|
||||
_labelUploadFile->setString(fileName);
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
@ -30,6 +30,10 @@
|
|||
"from": "../../../config.json",
|
||||
"to": ""
|
||||
},
|
||||
{
|
||||
"from": "../../../runtime/rtres",
|
||||
"to": "rtres"
|
||||
},
|
||||
{
|
||||
"from": "../../cocos2d-x/external/lua/luasocket",
|
||||
"to": "",
|
||||
|
|
|
@ -128,6 +128,8 @@
|
|||
C09BA7E718BC929700A85A3E /* WorkSpaceDialog.xib in Resources */ = {isa = PBXBuildFile; fileRef = C09BA7E418BC929700A85A3E /* WorkSpaceDialog.xib */; };
|
||||
C09BA7E818BC929700A85A3E /* WorkSpaceDialogController.mm in Sources */ = {isa = PBXBuildFile; fileRef = C09BA7E618BC929700A85A3E /* WorkSpaceDialogController.mm */; };
|
||||
C09BA7EE18BCA49600A85A3E /* NSAppSheetAdditions.m in Sources */ = {isa = PBXBuildFile; fileRef = C09BA7ED18BCA49600A85A3E /* NSAppSheetAdditions.m */; };
|
||||
C0F9D4BC192F3E6A0066134A /* rtres in Resources */ = {isa = PBXBuildFile; fileRef = C0F9D4BB192F3E6A0066134A /* rtres */; };
|
||||
C0F9D4BD192F3E6A0066134A /* rtres in Resources */ = {isa = PBXBuildFile; fileRef = C0F9D4BB192F3E6A0066134A /* rtres */; };
|
||||
D6B061351803AC000077942B /* CoreMotion.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = D6B061341803AC000077942B /* CoreMotion.framework */; };
|
||||
F293B3CD15EB7BE500256477 /* QuartzCore.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3CC15EB7BE500256477 /* QuartzCore.framework */; };
|
||||
F293B3D115EB7BE500256477 /* OpenAL.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = F293B3D015EB7BE500256477 /* OpenAL.framework */; };
|
||||
|
@ -394,6 +396,7 @@
|
|||
C09BA7E618BC929700A85A3E /* WorkSpaceDialogController.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = WorkSpaceDialogController.mm; sourceTree = "<group>"; };
|
||||
C09BA7EC18BCA49600A85A3E /* NSAppSheetAdditions.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NSAppSheetAdditions.h; sourceTree = "<group>"; };
|
||||
C09BA7ED18BCA49600A85A3E /* NSAppSheetAdditions.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = NSAppSheetAdditions.m; sourceTree = "<group>"; };
|
||||
C0F9D4BB192F3E6A0066134A /* rtres */ = {isa = PBXFileReference; lastKnownFileType = folder; name = rtres; path = ../../../runtime/rtres; sourceTree = "<group>"; };
|
||||
D6B061341803AC000077942B /* CoreMotion.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = CoreMotion.framework; path = Platforms/iPhoneOS.platform/Developer/SDKs/iPhoneOS7.0.sdk/System/Library/Frameworks/CoreMotion.framework; sourceTree = DEVELOPER_DIR; };
|
||||
F293B3C815EB7BE500256477 /* HelloLua iOS.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "HelloLua iOS.app"; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||
F293B3CC15EB7BE500256477 /* QuartzCore.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = QuartzCore.framework; path = System/Library/Frameworks/QuartzCore.framework; sourceTree = SDKROOT; };
|
||||
|
@ -642,6 +645,7 @@
|
|||
F293BC4615EB859D00256477 /* Resources */ = {
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
C0F9D4BB192F3E6A0066134A /* rtres */,
|
||||
C05D1C111923449100B808A4 /* config.json */,
|
||||
C03781B718BF655400FE4F13 /* res */,
|
||||
C03781B818BF655400FE4F13 /* src */,
|
||||
|
@ -852,6 +856,7 @@
|
|||
C08D5D5D18E567C6009071A4 /* ltn12.lua in Resources */,
|
||||
C03781EC18BF656A00FE4F13 /* luaoc.lua in Resources */,
|
||||
C07828F918B4D72E00BD2287 /* MainMenu.xib in Resources */,
|
||||
C0F9D4BD192F3E6A0066134A /* rtres in Resources */,
|
||||
5023817617EBBE3400990C9B /* Icon.icns in Resources */,
|
||||
C03781D218BF656A00FE4F13 /* CCBReaderLoad.lua in Resources */,
|
||||
C08D5D5F18E567C6009071A4 /* mbox.lua in Resources */,
|
||||
|
@ -894,6 +899,7 @@
|
|||
C03781F118BF656A00FE4F13 /* StudioConstants.lua in Resources */,
|
||||
5023811F17EBBCAC00990C9B /* Icon-152.png in Resources */,
|
||||
C03781D118BF656A00FE4F13 /* CCBReaderLoad.lua in Resources */,
|
||||
C0F9D4BC192F3E6A0066134A /* rtres in Resources */,
|
||||
5023812017EBBCAC00990C9B /* Icon-57.png in Resources */,
|
||||
C03781CF18BF656A00FE4F13 /* AudioEngine.lua in Resources */,
|
||||
C03781B918BF655400FE4F13 /* res in Resources */,
|
||||
|
|
|
@ -98,16 +98,16 @@ std::string getCurAppPath(void)
|
|||
return;
|
||||
}
|
||||
|
||||
if(!g_landscape)
|
||||
{
|
||||
float tmpvalue =width;
|
||||
width = height;
|
||||
height = tmpvalue;
|
||||
}
|
||||
|
||||
g_eglView = GLView::createWithRect([viewName cStringUsingEncoding:NSUTF8StringEncoding],cocos2d::Rect(0.0f,0.0f,width,height),frameZoomFactor);
|
||||
auto director = Director::getInstance();
|
||||
director->setOpenGLView(g_eglView);
|
||||
g_landscape = false;
|
||||
g_screenSize.width = width;
|
||||
g_screenSize.height = height;
|
||||
if (width > height)
|
||||
{
|
||||
g_landscape = true;
|
||||
}
|
||||
|
||||
window = glfwGetCocoaWindow(g_eglView->getWindow());
|
||||
[NSApp setDelegate: self];
|
||||
|
@ -124,12 +124,15 @@ void createSimulator(const char* viewName, float width, float height,bool isLand
|
|||
{
|
||||
if(g_nsAppDelegate)
|
||||
{
|
||||
if((isLandscape && height > width) || (!isLandscape && width > height))
|
||||
g_landscape = isLandscape;
|
||||
if(height > width)
|
||||
{
|
||||
float tmpvalue =width;
|
||||
width = height;
|
||||
height = tmpvalue;
|
||||
}
|
||||
g_screenSize.width = width;
|
||||
g_screenSize.height = height;
|
||||
|
||||
[g_nsAppDelegate createSimulator:[NSString stringWithUTF8String:viewName] viewWidth:width viewHeight:height factor:frameZoomFactor];
|
||||
}
|
||||
|
|
|
@ -109,9 +109,11 @@ if exist "$(OutDir)\Resource" rd /s /q "$(OutDir)\Resource"
|
|||
mkdir "$(OutDir)\Resource"
|
||||
mkdir "$(OutDir)\Resource\src"
|
||||
mkdir "$(OutDir)\Resource\res"
|
||||
mkdir "$(OutDir)\Resource\rtres"
|
||||
xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script" "$(OutDir)\Resource" /e /Y
|
||||
xcopy "$(ProjectDir)..\..\..\src" "$(OutDir)\Resource\src" /e /Y
|
||||
xcopy "$(ProjectDir)..\..\..\res" "$(OutDir)\Resource\res" /e /Y
|
||||
xcopy "$(ProjectDir)..\..\..\runtime\rtres" "$(OutDir)\Resource\rtres" /e /Y
|
||||
copy "$(ProjectDir)..\..\..\config.json" "$(OutDir)\Resource\config.json" /Y
|
||||
xcopy "$(ProjectDir)..\..\cocos2d-x\external\lua\luasocket\*.lua" "$(OutDir)\Resource" /e /Y</Command>
|
||||
<Message>copy files</Message>
|
||||
|
@ -165,9 +167,11 @@ if exist "$(OutDir)\Resource" rd /s /q "$(OutDir)\Resource"
|
|||
mkdir "$(OutDir)\Resource"
|
||||
mkdir "$(OutDir)\Resource\src"
|
||||
mkdir "$(OutDir)\Resource\res"
|
||||
mkdir "$(OutDir)\Resource\rtres"
|
||||
xcopy "$(ProjectDir)..\..\cocos2d-x\cocos\scripting\lua-bindings\script" "$(OutDir)\Resource" /e /Y
|
||||
xcopy "$(ProjectDir)..\..\..\src" "$(OutDir)\Resource\src" /e /Y
|
||||
xcopy "$(ProjectDir)..\..\..\res" "$(OutDir)\Resource\res" /e /Y
|
||||
xcopy "$(ProjectDir)..\..\..\runtime\rtres" "$(OutDir)\Resource\rtres" /e /Y
|
||||
copy "$(ProjectDir)..\..\..\config.json" "$(OutDir)\Resource\config.json" /Y
|
||||
xcopy "$(ProjectDir)..\..\cocos2d-x\external\lua\luasocket\*.lua" "$(OutDir)\Resource" /e /Y</Command>
|
||||
<Message>copy files</Message>
|
||||
|
|
|
@ -308,23 +308,26 @@ void createSimulator(const char* viewName, float width, float height, bool isLan
|
|||
return;
|
||||
}
|
||||
|
||||
if((isLandscape && height > width) || (!isLandscape && width > height))
|
||||
g_landscape = isLandscape;
|
||||
if(height > width)
|
||||
{
|
||||
float tmpvalue =width;
|
||||
width = height;
|
||||
height = tmpvalue;
|
||||
}
|
||||
|
||||
g_screenSize.width = width;
|
||||
g_screenSize.height = height;
|
||||
|
||||
if(!g_landscape)
|
||||
{
|
||||
float tmpvalue =width;
|
||||
width = height;
|
||||
height = tmpvalue;
|
||||
}
|
||||
|
||||
g_eglView = GLView::createWithRect(viewName,Rect(0,0,width,height),frameZoomFactor);
|
||||
auto director = Director::getInstance();
|
||||
director->setOpenGLView(g_eglView);
|
||||
g_landscape = false;
|
||||
g_screenSize.width = width;
|
||||
g_screenSize.height = height;
|
||||
if (width > height)
|
||||
{
|
||||
g_landscape = true;
|
||||
}
|
||||
|
||||
HWND hWnd=glfwGetWin32Window(g_eglView->getWindow());
|
||||
HMENU hMenu = LoadMenu(GetModuleHandle(NULL), MAKEINTRESOURCE(IDR_MENU_COCOS));
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
{
|
||||
"version":"v3-lua-runtime-1.1.1",
|
||||
"zip_file_size":"20854899",
|
||||
"version":"v3-lua-runtime-1.1.2",
|
||||
"zip_file_size":"21402175",
|
||||
"repo_name":"cocos-runtime-bin",
|
||||
"repo_parent":"https://github.com/chukong/"
|
||||
}
|
||||
|
|
Binary file not shown.
After Width: | Height: | Size: 24 KiB |
Binary file not shown.
After Width: | Height: | Size: 20 KiB |
Binary file not shown.
After Width: | Height: | Size: 147 KiB |
Binary file not shown.
After Width: | Height: | Size: 131 KiB |
Binary file not shown.
After Width: | Height: | Size: 12 KiB |
|
@ -373,7 +373,7 @@ void Effect3DOutline::drawWithSprite(EffectSprite3D* sprite, const Mat4 &transfo
|
|||
glBindBuffer(GL_ARRAY_BUFFER, mesh->getVertexBuffer());
|
||||
_glProgramState->apply(transform);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, mesh->getIndexBuffer());
|
||||
glDrawElements((GLenum)mesh->getPrimitiveType(), mesh->getIndexCount(), (GLenum)mesh->getIndexFormat(), 0);
|
||||
glDrawElements((GLenum)mesh->getPrimitiveType(), (GLsizei)mesh->getIndexCount(), (GLenum)mesh->getIndexFormat(), 0);
|
||||
glBindBuffer(GL_ELEMENT_ARRAY_BUFFER, 0);
|
||||
glBindBuffer(GL_ARRAY_BUFFER, 0);
|
||||
glDisable(GL_DEPTH_TEST);
|
||||
|
|
|
@ -1533,6 +1533,7 @@ void TextureAsync::onEnter()
|
|||
|
||||
TextureAsync::~TextureAsync()
|
||||
{
|
||||
Director::getInstance()->getTextureCache()->unbindAllImageAsync();
|
||||
Director::getInstance()->getTextureCache()->removeAllTextures();
|
||||
}
|
||||
|
||||
|
|
|
@ -60,13 +60,13 @@ bool UIScrollViewTest_Vertical::init()
|
|||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomInParent() - button->getSize().height));
|
||||
titleButton->setPosition(Vec2(innerWidth / 2.0f, button->getBottomBoundary() - button->getSize().height));
|
||||
scrollView->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomInParent() - titleButton->getSize().height));
|
||||
button_scale9->setPosition(Vec2(innerWidth / 2.0f, titleButton->getBottomBoundary() - titleButton->getSize().height));
|
||||
scrollView->addChild(button_scale9);
|
||||
|
||||
imageView->setPosition(Vec2(innerWidth / 2.0f, imageView->getSize().height / 2.0f));
|
||||
|
@ -137,19 +137,19 @@ bool UIScrollViewTest_Horizontal::init()
|
|||
|
||||
Button* titleButton = Button::create("cocosui/backtotopnormal.png", "cocosui/backtotoppressed.png");
|
||||
titleButton->setTitleText("Title Button");
|
||||
titleButton->setPosition(Vec2(button->getRightInParent() + button->getSize().width / 2.0f,
|
||||
button->getBottomInParent() - button->getSize().height / 2.0f));
|
||||
titleButton->setPosition(Vec2(button->getRightBoundary() + button->getSize().width / 2.0f,
|
||||
button->getBottomBoundary() - button->getSize().height / 2.0f));
|
||||
scrollView->addChild(titleButton);
|
||||
|
||||
Button* button_scale9 = Button::create("cocosui/button.png", "cocosui/buttonHighlighted.png");
|
||||
button_scale9->setScale9Enabled(true);
|
||||
button_scale9->setSize(Size(100.0f, button_scale9->getVirtualRendererSize().height));
|
||||
button_scale9->setPosition(Vec2(titleButton->getRightInParent() + titleButton->getSize().width / 2.0f,
|
||||
titleButton->getBottomInParent() - titleButton->getSize().height / 2.0f));
|
||||
button_scale9->setPosition(Vec2(titleButton->getRightBoundary() + titleButton->getSize().width / 2.0f,
|
||||
titleButton->getBottomBoundary() - titleButton->getSize().height / 2.0f));
|
||||
scrollView->addChild(button_scale9);
|
||||
|
||||
imageView->setPosition(Vec2(innerWidth - imageView->getSize().width / 2.0f,
|
||||
button_scale9->getBottomInParent() - button_scale9->getSize().height / 2.0f));
|
||||
button_scale9->getBottomBoundary() - button_scale9->getSize().height / 2.0f));
|
||||
scrollView->addChild(imageView);
|
||||
|
||||
return true;
|
||||
|
|
Binary file not shown.
|
@ -70,6 +70,8 @@
|
|||
</array>
|
||||
<key>UIPrerenderedIcon</key>
|
||||
<true/>
|
||||
<key>UIStatusBarHidden</key>
|
||||
<true/>
|
||||
<key>UISupportedInterfaceOrientations</key>
|
||||
<array>
|
||||
<string>UIInterfaceOrientationLandscapeRight</string>
|
||||
|
|
|
@ -36,14 +36,9 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
|
||||
auto designSize = Size(480, 320);
|
||||
|
||||
auto pFileUtils = FileUtils::getInstance();
|
||||
|
||||
if (screenSize.height > 320)
|
||||
{
|
||||
auto resourceSize = Size(960, 640);
|
||||
std::vector<std::string> searchPaths;
|
||||
searchPaths.push_back("hd");
|
||||
pFileUtils->setSearchPaths(searchPaths);
|
||||
director->setContentScaleFactor(resourceSize.height/designSize.height);
|
||||
}
|
||||
|
||||
|
@ -58,51 +53,6 @@ bool AppDelegate::applicationDidFinishLaunching()
|
|||
register_assetsmanager_test_sample(stack->getLuaState());
|
||||
#endif
|
||||
|
||||
#if (CC_TARGET_PLATFORM == CC_PLATFORM_IOS || CC_TARGET_PLATFORM == CC_PLATFORM_MAC)
|
||||
std::string resPrefix("");
|
||||
#else
|
||||
std::string resPrefix("res/");
|
||||
#endif
|
||||
|
||||
std::vector<std::string> searchPaths = pFileUtils->getSearchPaths();
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix);
|
||||
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "cocosbuilderRes");
|
||||
if (screenSize.height > 320)
|
||||
{
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "hd");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/Images");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/ArmatureComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/AttributeComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/BackgroundComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/EffectComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/ParticleComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/SpriteComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/TmxMapComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/UIComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/hd/scenetest/TriggerTest");
|
||||
}
|
||||
else
|
||||
{
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/Images");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/ArmatureComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/AttributeComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/BackgroundComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/EffectComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/LoadSceneEdtiorFileTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/ParticleComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/SpriteComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/TmxMapComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/UIComponentTest");
|
||||
searchPaths.insert(searchPaths.begin(), resPrefix + "ccs-res/scenetest/TriggerTest");
|
||||
}
|
||||
|
||||
|
||||
FileUtils::getInstance()->setSearchPaths(searchPaths);
|
||||
|
||||
pEngine->executeScriptFile("src/controller.lua");
|
||||
|
||||
return true;
|
||||
|
|
|
@ -1,6 +1,25 @@
|
|||
require "OpenglConstants"
|
||||
require "Cocos2dConstants"
|
||||
require "Opengl"
|
||||
|
||||
local vertDefaultSource = "\n".."\n" ..
|
||||
"attribute vec4 a_position;\n" ..
|
||||
"attribute vec2 a_texCoord;\n" ..
|
||||
"attribute vec4 a_color;\n\n" ..
|
||||
"\n#ifdef GL_ES\n" ..
|
||||
"varying lowp vec4 v_fragmentColor;\n" ..
|
||||
"varying mediump vec2 v_texCoord;\n" ..
|
||||
"\n#else\n" ..
|
||||
"varying vec4 v_fragmentColor;" ..
|
||||
"varying vec2 v_texCoord;" ..
|
||||
"\n#endif\n" ..
|
||||
"void main()\n" ..
|
||||
"{\n" ..
|
||||
" gl_Position = CC_MVPMatrix * a_position;\n"..
|
||||
" v_fragmentColor = a_color;\n"..
|
||||
" v_texCoord = a_texCoord;\n" ..
|
||||
"} \n"
|
||||
|
||||
local function OpenGLTestMainLayer()
|
||||
local kItemTagBasic = 1000
|
||||
local testCount = 16
|
||||
|
@ -174,122 +193,80 @@ local function OpenGLTestMainLayer()
|
|||
end
|
||||
|
||||
local function createShaderMajoriTest()
|
||||
local uniformCenter = 0
|
||||
local uniformResolution = 0
|
||||
local time = 0
|
||||
local squareVertexPositionBuffer = {}
|
||||
local majorLayer = cc.Layer:create()
|
||||
|
||||
InitTitle(majorLayer)
|
||||
--loadShaderVertex
|
||||
local shader = cc.GLProgram:create("Shaders/example_Monjori.vsh", "Shaders/example_Monjori.fsh")
|
||||
|
||||
shader:bindAttribLocation("aVertex", cc.VERTEX_ATTRIB_POSITION)
|
||||
shader:link()
|
||||
shader:updateUniforms()
|
||||
local fileUtiles = cc.FileUtils:getInstance()
|
||||
|
||||
local program = shader:getProgram()
|
||||
local vertSource = vertDefaultSource
|
||||
local fragSource = fileUtiles:getStringFromFile("Shaders/example_Monjori.fsh")
|
||||
local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource)
|
||||
local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam)
|
||||
local resolution = cc.p(256, 256)
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(256, 256))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
uniformCenter = gl.getUniformLocation(program,"center")
|
||||
uniformResolution = gl.getUniformLocation( program, "resolution")
|
||||
glNode:setGLProgram(shader)
|
||||
|
||||
local function initBuffer()
|
||||
squareVertexPositionBuffer = gl.createBuffer()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer)
|
||||
local vertices = { 256,256,0,256,256,0,0,0}
|
||||
gl.bufferData(gl.ARRAY_BUFFER,8,vertices,gl.STATIC_DRAW)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
end
|
||||
glNode:setGLProgramState(glprogramstate)
|
||||
glNode:getGLProgramState():setUniformVec2("resolution", resolution)
|
||||
|
||||
local function updateMajori(fTime)
|
||||
time = time + fTime
|
||||
end
|
||||
|
||||
local function majoriDraw(transform, transformUpdated)
|
||||
if nil ~= shader then
|
||||
shader:use()
|
||||
shader:setUniformsForBuiltins(transform)
|
||||
--Uniforms
|
||||
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
|
||||
shader:setUniformLocationF32( uniformResolution, 256, 256)
|
||||
local w = 256
|
||||
local h = 256
|
||||
|
||||
gl.glEnableVertexAttribs(cc.VERTEX_ATTRIB_FLAG_POSITION)
|
||||
|
||||
--Draw fullscreen Square
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,0)
|
||||
end
|
||||
local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h }
|
||||
local glProgramState = glNode:getGLProgramState()
|
||||
glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices)
|
||||
glProgramState:apply(transform)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6)
|
||||
end
|
||||
initBuffer()
|
||||
|
||||
majorLayer:scheduleUpdateWithPriorityLua(updateMajori,0)
|
||||
glNode:registerScriptDrawHandler(majoriDraw)
|
||||
time = 0
|
||||
majorLayer:addChild(glNode,-10)
|
||||
print("pos is ", size.width/2, size.height/2)
|
||||
glNode:setPosition( size.width/2, size.height/2)
|
||||
return majorLayer
|
||||
end
|
||||
|
||||
local function createShaderMandelbrotTest()
|
||||
local uniformCenter = 0
|
||||
local uniformResolution = 0
|
||||
local time = 0
|
||||
local squareVertexPositionBuffer = {}
|
||||
local mandelbrotLayer = cc.Layer:create()
|
||||
|
||||
InitTitle(mandelbrotLayer)
|
||||
--loadShaderVertex
|
||||
local shader = cc.GLProgram:create("Shaders/example_Mandelbrot.vsh", "Shaders/example_Mandelbrot.fsh")
|
||||
|
||||
shader:bindAttribLocation("aVertex", 0)
|
||||
shader:link()
|
||||
shader:updateUniforms()
|
||||
|
||||
local program = shader:getProgram()
|
||||
local fileUtiles = cc.FileUtils:getInstance()
|
||||
local vertSource = vertDefaultSource
|
||||
local fragSource = fileUtiles:getStringFromFile("Shaders/example_Mandelbrot.fsh")
|
||||
local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource)
|
||||
local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam)
|
||||
local resolution = cc.p(256, 256)
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(256,256))
|
||||
glNode:setContentSize(cc.size(256, 256))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
uniformCenter = gl.getUniformLocation(program,"center")
|
||||
uniformResolution = gl.getUniformLocation( program, "resolution")
|
||||
glNode:setGLProgram(shader)
|
||||
|
||||
local function initBuffer()
|
||||
squareVertexPositionBuffer.buffer_id = gl.createBuffer()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
local vertices = { 256,256,0,256,256,0,0,0}
|
||||
gl.bufferData(gl.ARRAY_BUFFER,8,vertices,gl.STATIC_DRAW)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
end
|
||||
glNode:setGLProgramState(glprogramstate)
|
||||
glNode:getGLProgramState():setUniformVec2("resolution", resolution)
|
||||
|
||||
local function updateMandelbrot(fTime)
|
||||
time = time + fTime
|
||||
end
|
||||
|
||||
local function mandelbrotDraw(transform, transformUpdated)
|
||||
if nil ~= shader then
|
||||
shader:use()
|
||||
shader:setUniformsForBuiltins(transform)
|
||||
--Uniforms
|
||||
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
|
||||
shader:setUniformLocationF32( uniformResolution, 256, 256)
|
||||
local w = 256
|
||||
local h = 256
|
||||
|
||||
gl.glEnableVertexAttribs(0x1)
|
||||
|
||||
--Draw fullscreen Square
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,0)
|
||||
end
|
||||
local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h }
|
||||
local glProgramState = glNode:getGLProgramState()
|
||||
glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices)
|
||||
glProgramState:apply(transform)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6)
|
||||
end
|
||||
initBuffer()
|
||||
|
||||
mandelbrotLayer:scheduleUpdateWithPriorityLua(updateMandelbrot,0)
|
||||
glNode:registerScriptDrawHandler(mandelbrotDraw)
|
||||
time = 0
|
||||
|
@ -299,59 +276,39 @@ local function OpenGLTestMainLayer()
|
|||
end
|
||||
|
||||
local function createShaderHeartTest()
|
||||
local uniformCenter = 0
|
||||
local uniformResolution = 0
|
||||
local time = 0
|
||||
local squareVertexPositionBuffer = {}
|
||||
|
||||
local heartLayer = cc.Layer:create()
|
||||
|
||||
InitTitle(heartLayer)
|
||||
--loadShaderVertex
|
||||
local shader = cc.GLProgram:create("Shaders/example_Heart.vsh", "Shaders/example_Heart.fsh")
|
||||
|
||||
shader:bindAttribLocation("aVertex", 0)
|
||||
shader:link()
|
||||
shader:updateUniforms()
|
||||
|
||||
local program = shader:getProgram()
|
||||
local fileUtiles = cc.FileUtils:getInstance()
|
||||
local vertSource = vertDefaultSource
|
||||
local fragSource = fileUtiles:getStringFromFile("Shaders/example_Heart.fsh")
|
||||
local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource)
|
||||
local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam)
|
||||
local resolution = cc.p(256, 256)
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(256,256))
|
||||
glNode:setContentSize(cc.size(256, 256))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
uniformCenter = gl.getUniformLocation(program,"center")
|
||||
uniformResolution = gl.getUniformLocation( program, "resolution")
|
||||
glNode:setGLProgram(shader)
|
||||
|
||||
local function initBuffer()
|
||||
squareVertexPositionBuffer.buffer_id = gl.createBuffer()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
local vertices = { 256,256,0,256,256,0,0,0}
|
||||
gl.bufferData(gl.ARRAY_BUFFER,8,vertices,gl.STATIC_DRAW)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
end
|
||||
glNode:setGLProgramState(glprogramstate)
|
||||
glNode:getGLProgramState():setUniformVec2("resolution", resolution)
|
||||
|
||||
local function updateHeart(fTime)
|
||||
time = time + fTime
|
||||
end
|
||||
|
||||
local function heartDraw(transform, transformUpdated)
|
||||
if nil ~= shader then
|
||||
shader:use()
|
||||
shader:setUniformsForBuiltins(transform)
|
||||
--Uniforms
|
||||
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
|
||||
shader:setUniformLocationF32( uniformResolution, 256, 256)
|
||||
local w = 256
|
||||
local h = 256
|
||||
|
||||
gl.glEnableVertexAttribs(0x1)
|
||||
|
||||
--Draw fullscreen Square
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,0)
|
||||
end
|
||||
local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h }
|
||||
local glProgramState = glNode:getGLProgramState()
|
||||
glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices)
|
||||
glProgramState:apply(transform)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6)
|
||||
end
|
||||
initBuffer()
|
||||
|
||||
heartLayer:scheduleUpdateWithPriorityLua(updateHeart,0)
|
||||
glNode:registerScriptDrawHandler(heartDraw)
|
||||
time = 0
|
||||
|
@ -361,59 +318,40 @@ local function OpenGLTestMainLayer()
|
|||
end
|
||||
|
||||
local function createShaderPlasmaTest()
|
||||
local uniformCenter = 0
|
||||
local uniformResolution = 0
|
||||
local time = 0
|
||||
local squareVertexPositionBuffer = {}
|
||||
|
||||
local plasmaLayer = cc.Layer:create()
|
||||
|
||||
InitTitle(plasmaLayer)
|
||||
--loadShaderVertex
|
||||
local shader = cc.GLProgram:create("Shaders/example_Plasma.vsh", "Shaders/example_Plasma.fsh")
|
||||
|
||||
shader:bindAttribLocation("aVertex", 0)
|
||||
shader:link()
|
||||
shader:updateUniforms()
|
||||
|
||||
local program = shader:getProgram()
|
||||
local fileUtiles = cc.FileUtils:getInstance()
|
||||
local vertSource = vertDefaultSource
|
||||
local fragSource = fileUtiles:getStringFromFile("Shaders/example_Plasma.fsh")
|
||||
local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource)
|
||||
local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam)
|
||||
local resolution = cc.p(256, 256)
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(256,256))
|
||||
glNode:setContentSize(cc.size(256, 256))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
uniformCenter = gl.getUniformLocation(program,"center")
|
||||
uniformResolution = gl.getUniformLocation( program, "resolution")
|
||||
glNode:setGLProgram(shader)
|
||||
glNode:setGLProgramState(glprogramstate)
|
||||
glNode:getGLProgramState():setUniformVec2("resolution", resolution)
|
||||
|
||||
local function initBuffer()
|
||||
squareVertexPositionBuffer.buffer_id = gl.createBuffer()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
local vertices = { 256,256,0,256,256,0,0,0}
|
||||
gl.bufferData(gl.ARRAY_BUFFER,8,vertices,gl.STATIC_DRAW)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
end
|
||||
|
||||
local function updatePlasma(fTime)
|
||||
time = time + fTime
|
||||
end
|
||||
|
||||
local function plasmaDraw(transform, transformUpdated)
|
||||
if nil ~= shader then
|
||||
shader:use()
|
||||
shader:setUniformsForBuiltins(transform)
|
||||
--Uniforms
|
||||
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
|
||||
shader:setUniformLocationF32( uniformResolution, 256, 256)
|
||||
local w = 256
|
||||
local h = 256
|
||||
|
||||
gl.glEnableVertexAttribs(0x1)
|
||||
|
||||
--Draw fullscreen Square
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,0)
|
||||
end
|
||||
local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h }
|
||||
local glProgramState = glNode:getGLProgramState()
|
||||
glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices)
|
||||
glProgramState:apply(transform)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6)
|
||||
end
|
||||
initBuffer()
|
||||
|
||||
plasmaLayer:scheduleUpdateWithPriorityLua(updatePlasma,0)
|
||||
glNode:registerScriptDrawHandler(plasmaDraw)
|
||||
time = 0
|
||||
|
@ -423,59 +361,39 @@ local function OpenGLTestMainLayer()
|
|||
end
|
||||
|
||||
local function createShaderFlowerTest()
|
||||
local uniformCenter = 0
|
||||
local uniformResolution = 0
|
||||
local time = 0
|
||||
local squareVertexPositionBuffer = {}
|
||||
|
||||
local flowerLayer = cc.Layer:create()
|
||||
|
||||
InitTitle(flowerLayer)
|
||||
--loadShaderVertex
|
||||
local shader = cc.GLProgram:create("Shaders/example_Flower.vsh", "Shaders/example_Flower.fsh")
|
||||
|
||||
shader:bindAttribLocation("aVertex", 0)
|
||||
shader:link()
|
||||
shader:updateUniforms()
|
||||
|
||||
local program = shader:getProgram()
|
||||
local fileUtiles = cc.FileUtils:getInstance()
|
||||
local vertSource = vertDefaultSource
|
||||
local fragSource = fileUtiles:getStringFromFile("Shaders/example_Flower.fsh")
|
||||
local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource)
|
||||
local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam)
|
||||
local resolution = cc.p(256, 256)
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(256,256))
|
||||
glNode:setContentSize(cc.size(256, 256))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
uniformCenter = gl.getUniformLocation(program,"center")
|
||||
uniformResolution = gl.getUniformLocation( program, "resolution")
|
||||
glNode:setGLProgram(shader)
|
||||
|
||||
local function initBuffer()
|
||||
squareVertexPositionBuffer.buffer_id = gl.createBuffer()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
local vertices = { 256,256,0,256,256,0,0,0}
|
||||
gl.bufferData(gl.ARRAY_BUFFER,8,vertices,gl.STATIC_DRAW)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
end
|
||||
glNode:setGLProgramState(glprogramstate)
|
||||
glNode:getGLProgramState():setUniformVec2("resolution", resolution)
|
||||
|
||||
local function updateFlower(fTime)
|
||||
time = time + fTime
|
||||
end
|
||||
|
||||
local function flowerDraw(transform, transformUpdated)
|
||||
if nil ~= shader then
|
||||
shader:use()
|
||||
shader:setUniformsForBuiltins(transform)
|
||||
--Uniforms
|
||||
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
|
||||
shader:setUniformLocationF32( uniformResolution, 256, 256)
|
||||
local w = 256
|
||||
local h = 256
|
||||
|
||||
gl.glEnableVertexAttribs(0x1)
|
||||
|
||||
--Draw fullscreen Square
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,0)
|
||||
end
|
||||
local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h }
|
||||
local glProgramState = glNode:getGLProgramState()
|
||||
glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices)
|
||||
glProgramState:apply(transform)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6)
|
||||
end
|
||||
initBuffer()
|
||||
|
||||
flowerLayer:scheduleUpdateWithPriorityLua(updateFlower,0)
|
||||
glNode:registerScriptDrawHandler(flowerDraw)
|
||||
time = 0
|
||||
|
@ -485,59 +403,39 @@ local function OpenGLTestMainLayer()
|
|||
end
|
||||
|
||||
local function createShaderJuliaTest()
|
||||
local uniformCenter = 0
|
||||
local uniformResolution = 0
|
||||
local time = 0
|
||||
local squareVertexPositionBuffer = {}
|
||||
|
||||
local juliaLayer = cc.Layer:create()
|
||||
|
||||
InitTitle(juliaLayer)
|
||||
--loadShaderVertex
|
||||
local shader = cc.GLProgram:create("Shaders/example_Julia.vsh", "Shaders/example_Julia.fsh")
|
||||
|
||||
shader:bindAttribLocation("aVertex", 0)
|
||||
shader:link()
|
||||
shader:updateUniforms()
|
||||
|
||||
local program = shader:getProgram()
|
||||
local fileUtiles = cc.FileUtils:getInstance()
|
||||
local vertSource = vertDefaultSource
|
||||
local fragSource = fileUtiles:getStringFromFile("Shaders/example_Julia.fsh")
|
||||
local glProgam = cc.GLProgram:createWithByteArrays(vertSource, fragSource)
|
||||
local glprogramstate = cc.GLProgramState:getOrCreateWithGLProgram(glProgam)
|
||||
local resolution = cc.p(256, 256)
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(256,256))
|
||||
glNode:setContentSize(cc.size(256, 256))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
uniformCenter = gl.getUniformLocation(program,"center")
|
||||
uniformResolution = gl.getUniformLocation( program, "resolution")
|
||||
glNode:setGLProgram(shader)
|
||||
|
||||
local function initBuffer()
|
||||
squareVertexPositionBuffer.buffer_id = gl.createBuffer()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
local vertices = { 256,256,0,256,256,0,0,0}
|
||||
gl.bufferData(gl.ARRAY_BUFFER,8,vertices,gl.STATIC_DRAW)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
end
|
||||
glNode:setGLProgramState(glprogramstate)
|
||||
glNode:getGLProgramState():setUniformVec2("resolution", resolution)
|
||||
|
||||
local function updateJulia(fTime)
|
||||
time = time + fTime
|
||||
end
|
||||
|
||||
local function juliaDraw(transform, transformUpdated)
|
||||
if nil ~= shader then
|
||||
shader:use()
|
||||
shader:setUniformsForBuiltins(transform)
|
||||
--Uniforms
|
||||
shader:setUniformLocationF32( uniformCenter, size.width/2, size.height/2)
|
||||
shader:setUniformLocationF32( uniformResolution, 256, 256)
|
||||
local w = 256
|
||||
local h = 256
|
||||
|
||||
gl.glEnableVertexAttribs(0x1)
|
||||
|
||||
--Draw fullscreen Square
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,squareVertexPositionBuffer.buffer_id)
|
||||
gl.vertexAttribPointer(cc.VERTEX_ATTRIB_POSITION, 2, gl.FLOAT, false, 0, 0)
|
||||
gl.drawArrays(gl.TRIANGLE_STRIP,0,4)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER,0)
|
||||
end
|
||||
local vertices ={ 0,0, w,0, w,h, 0,0, 0,h, w,h }
|
||||
local glProgramState = glNode:getGLProgramState()
|
||||
glProgramState:setVertexAttribPointer("a_position", 2, gl.FLOAT, false, 0, vertices, #vertices)
|
||||
glProgramState:apply(transform)
|
||||
gl.drawArrays(gl.TRIANGLES, 0, 6)
|
||||
end
|
||||
initBuffer()
|
||||
|
||||
juliaLayer:scheduleUpdateWithPriorityLua(updateJulia,0)
|
||||
glNode:registerScriptDrawHandler(juliaDraw)
|
||||
time = 0
|
||||
|
@ -606,6 +504,7 @@ local function OpenGLTestMainLayer()
|
|||
glNode:setAnchorPoint(cc.p(0.5,0.5))
|
||||
local shaderCache = cc.ShaderCache:getInstance()
|
||||
local shader = shaderCache:getProgram("ShaderPositionTexture")
|
||||
|
||||
local function initGL()
|
||||
texture.texture_id = gl.createTexture()
|
||||
gl.bindTexture(gl.TEXTURE_2D,texture.texture_id )
|
||||
|
|
|
@ -1,12 +1,4 @@
|
|||
local size = cc.Director:getInstance():getWinSize()
|
||||
local attributeNames =
|
||||
{
|
||||
"a_position",
|
||||
"a_color",
|
||||
"a_texCoord",
|
||||
"a_normal",
|
||||
}
|
||||
|
||||
|
||||
----------------------------------------
|
||||
----Sprite3DBasicTest
|
||||
|
@ -66,198 +58,6 @@ function Sprite3DBasicTest.create()
|
|||
return layer
|
||||
end
|
||||
|
||||
----------------------------------------
|
||||
----Sprite3DEffectTest
|
||||
----------------------------------------
|
||||
|
||||
local Effect3DOutline = class("Effect3DOutline")
|
||||
Effect3DOutline.__index = Effect3DOutline
|
||||
|
||||
function Effect3DOutline:ctor()
|
||||
self.outlineWidth = 0.0
|
||||
self.outlineColor = { x = 1, y = 1, z = 1}
|
||||
self.glProgramState = nil
|
||||
self.vertShaderFile = "Shaders3D/OutLine.vert"
|
||||
self.fragShaderFile = "Shaders3D/OutLine.frag"
|
||||
self.keyInGLProgramCache = "Effect3DLibrary_Outline"
|
||||
|
||||
if self:init() then
|
||||
return self
|
||||
else
|
||||
return nil
|
||||
end
|
||||
end
|
||||
|
||||
function Effect3DOutline:getOrCreateProgram()
|
||||
|
||||
local program = cc.GLProgramCache:getInstance():getGLProgram(self.keyInGLProgramCache)
|
||||
|
||||
if nil == program then
|
||||
program = cc.GLProgram:createWithFilenames(self.vertShaderFile , self.fragShaderFile)
|
||||
cc.GLProgramCache:getInstance():addGLProgram(program, self.keyInGLProgramCache)
|
||||
end
|
||||
print(program)
|
||||
return program
|
||||
end
|
||||
|
||||
function Effect3DOutline:init()
|
||||
local program = self:getOrCreateProgram()
|
||||
if nil == program then
|
||||
return false
|
||||
end
|
||||
|
||||
self.glProgramState = cc.GLProgramState:create(program)
|
||||
if nil == self.glProgramState then
|
||||
return false
|
||||
end
|
||||
|
||||
self.glProgramState:retain()
|
||||
self.glProgramState:setUniformVec3("OutLineColor", self.outlineColor)
|
||||
self.glProgramState:setUniformFloat("OutlineWidth", self.outlineWidth)
|
||||
|
||||
return true
|
||||
end
|
||||
|
||||
|
||||
function Effect3DOutline:setOutlineColor(color)
|
||||
if self.outlineColor.x ~= color.x and self.outlineColor.y ~= color.y or self.outlineColor.z ~= color.z then
|
||||
self.outlineColor.x = color.x
|
||||
self.outlineColor.y = color.y
|
||||
self.outlineColor.z = color.z
|
||||
self.glProgramState:setUniformVec3("OutLineColor", self.outlineColor)
|
||||
end
|
||||
end
|
||||
|
||||
function Effect3DOutline:setOutlineWidth(width)
|
||||
if self.outlineWidth ~= width then
|
||||
self.outlineWidth = width
|
||||
self.glProgramState:setUniformFloat("OutlineWidth", self.outlineWidth )
|
||||
end
|
||||
end
|
||||
|
||||
function Effect3DOutline:drawWithSprite(sprite, transform)
|
||||
|
||||
local mesh = sprite:getMesh()
|
||||
local offset = 0
|
||||
for i = 1, mesh:getMeshVertexAttribCount() do
|
||||
local meshvertexattrib = mesh:getMeshVertexAttribute(i - 1)
|
||||
self.glProgramState:setVertexAttribPointer(attributeNames[meshvertexattrib.vertexAttrib + 1], meshvertexattrib.size, meshvertexattrib.type, false, mesh:getVertexSizeInBytes(), offset)
|
||||
offset = offset + meshvertexattrib.attribSizeBytes
|
||||
end
|
||||
|
||||
--draw
|
||||
gl.enable(gl.CULL_FACE)
|
||||
gl.cullFace(gl.FRONT)
|
||||
gl.enable(gl.DEPTH_TEST)
|
||||
|
||||
local color = sprite:getDisplayedColor()
|
||||
color.a = sprite:getDisplayedOpacity() / 255.0
|
||||
self.glProgramState:setUniformVec4("u_color", {x = color.r / 255.0, y = color.g / 255.0, z = color.b / 255.0, w = 1.0})
|
||||
|
||||
mesh = sprite:getMesh()
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, mesh:getVertexBuffer())
|
||||
self.glProgramState:apply(transform)
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, mesh:getIndexBuffer())
|
||||
gl.drawElements(mesh:getPrimitiveType(), mesh:getIndexCount(), mesh:getIndexFormat(), 0)
|
||||
gl.bindBuffer(gl.ELEMENT_ARRAY_BUFFER, 0)
|
||||
gl.bindBuffer(gl.ARRAY_BUFFER, 0)
|
||||
gl.disable(gl.DEPTH_TEST)
|
||||
gl.cullFace(gl.BACK)
|
||||
gl.disable(gl.CULL_FACE)
|
||||
end
|
||||
|
||||
|
||||
local EffectSprite3D = class("EffectSprite3D")
|
||||
EffectSprite3D.__index = EffectSprite3D
|
||||
|
||||
function EffectSprite3D.extend(target)
|
||||
local t = tolua.getpeer(target)
|
||||
if not t then
|
||||
t = {}
|
||||
tolua.setpeer(target, t)
|
||||
end
|
||||
setmetatable(t, EffectSprite3D)
|
||||
return target
|
||||
end
|
||||
|
||||
function EffectSprite3D:init()
|
||||
self.effects = {}
|
||||
self.defaultEffect = nil
|
||||
end
|
||||
|
||||
function EffectSprite3D.createFromObjFileAndTexture(objFilePath, textureFilePath)
|
||||
local sprite = EffectSprite3D.extend(cc.Sprite3D:create(objFilePath))
|
||||
sprite:setTexture(textureFilePath)
|
||||
return sprite
|
||||
end
|
||||
|
||||
|
||||
local Sprite3DEffectTest = {}
|
||||
Sprite3DEffectTest.__index = Sprite3DEffectTest
|
||||
|
||||
function Sprite3DEffectTest.onTouchesEnd(touches, event)
|
||||
for i = 1,table.getn(touches) do
|
||||
local location = touches[i]:getLocation()
|
||||
Sprite3DEffectTest.addNewSpriteWithCoords(Helper.currentLayer, location.x, location.y )
|
||||
end
|
||||
end
|
||||
|
||||
function Sprite3DEffectTest.addNewSpriteWithCoords(layer, x, y)
|
||||
local sprite = EffectSprite3D.createFromObjFileAndTexture("Sprite3DTest/boss1.obj", "Sprite3DTest/boss.png")
|
||||
sprite:setScale(6.0)
|
||||
layer:addChild(sprite)
|
||||
sprite:setPosition(cc.p(x, y))
|
||||
|
||||
local effect = Effect3DOutline.new()
|
||||
effect:setOutlineColor({x = 1, y = 0, z =0})
|
||||
effect:setOutlineWidth(0.1)
|
||||
local effect2 = Effect3DOutline.new()
|
||||
effect2:setOutlineWidth(0.02)
|
||||
effect2:setOutlineColor({x = 1, y = 1, z =0})
|
||||
|
||||
|
||||
local function onDraw(transform, transformUpdated)
|
||||
effect:drawWithSprite(sprite, transform)
|
||||
effect2:drawWithSprite(sprite, transform)
|
||||
end
|
||||
|
||||
local random = math.random(0, 1)
|
||||
local action = nil
|
||||
if random < 0.2 then
|
||||
action = cc.ScaleBy:create(3,2)
|
||||
elseif random < 0.4 then
|
||||
action = cc.RotateBy:create(3, 360)
|
||||
elseif random < 0.6 then
|
||||
action = cc.Blink:create(1, 3)
|
||||
elseif random < 0.8 then
|
||||
action = cc.TintBy:create(2, 0, -255, -255)
|
||||
else
|
||||
action = cc.FadeOut:create(2)
|
||||
end
|
||||
|
||||
local action_back = action:reverse()
|
||||
local seq = cc.Sequence:create(action, action_back)
|
||||
|
||||
sprite:runAction(cc.RepeatForever:create(seq))
|
||||
|
||||
local glNode = gl.glNodeCreate()
|
||||
glNode:setContentSize(cc.size(size.width, size.height))
|
||||
glNode:setAnchorPoint(cc.p(0.5, 0.5))
|
||||
glNode:setPosition( size.width / 2, size.height / 2)
|
||||
glNode:registerScriptDrawHandler(onDraw)
|
||||
layer:addChild(glNode,-10)
|
||||
|
||||
end
|
||||
|
||||
function Sprite3DEffectTest.create()
|
||||
local layer = cc.Layer:create()
|
||||
Helper.initWithLayer(layer)
|
||||
Helper.titleLabel:setString("Testing Sprite3D")
|
||||
Helper.subtitleLabel:setString("Sprite3d with effects")
|
||||
|
||||
Sprite3DEffectTest.addNewSpriteWithCoords(layer, size.width / 2, size.height / 2)
|
||||
return layer
|
||||
end
|
||||
|
||||
function Sprite3DTest()
|
||||
local scene = cc.Scene:create()
|
||||
|
@ -265,7 +65,6 @@ function Sprite3DTest()
|
|||
Helper.createFunctionTable =
|
||||
{
|
||||
Sprite3DBasicTest.create,
|
||||
Sprite3DEffectTest.create,
|
||||
}
|
||||
|
||||
scene:addChild(Sprite3DBasicTest.create())
|
||||
|
|
|
@ -1264,16 +1264,33 @@ local function TextureMemoryAlloc()
|
|||
cc.Director:getInstance():getTextureCache():removeUnusedTextures()
|
||||
|
||||
local file = ""
|
||||
if tag == 0 then
|
||||
file = "Images/test_1021x1024.png"
|
||||
elseif tag == 1 then
|
||||
file = "Images/test_1021x1024_rgba8888.pvr"
|
||||
elseif tag == 2 then
|
||||
file = "Images/test_1021x1024_rgb888.pvr"
|
||||
elseif tag == 3 then
|
||||
file = "Images/test_1021x1024_rgba4444.pvr"
|
||||
elseif tag == 4 then
|
||||
file = "Images/test_1021x1024_a8.pvr"
|
||||
|
||||
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||
|
||||
if cc.PLATFORM_OS_ANDROID == targetPlatform then
|
||||
if tag == 0 then
|
||||
file = "Images/background.png"
|
||||
elseif tag == 1 then
|
||||
file = "Images/fire_rgba8888.pvr"
|
||||
elseif tag == 2 then
|
||||
file = "Images/grossini_prv_rgba8888.pvr"
|
||||
elseif tag == 3 then
|
||||
file = "Images/grossini_prv_rgba4444.pvr"
|
||||
elseif tag == 4 then
|
||||
file = "Images/test_image_a8.pvr"
|
||||
end
|
||||
else
|
||||
if tag == 0 then
|
||||
file = "Images/background.png"
|
||||
elseif tag == 1 then
|
||||
file = "Images/test_image_rgba4444.pvr.gz"
|
||||
elseif tag == 2 then
|
||||
file = "Images/test_image_rgba4444.pvr.gz"
|
||||
elseif tag == 3 then
|
||||
file = "Images/test_image_rgba4444.pvr.gz"
|
||||
elseif tag == 4 then
|
||||
file = "Images/test_image_rgba4444.pvr.gz"
|
||||
end
|
||||
end
|
||||
|
||||
m_pBackground = cc.Sprite:create(file)
|
||||
|
|
|
@ -8,6 +8,65 @@ require "src/mainMenu"
|
|||
|
||||
|
||||
-- run
|
||||
|
||||
local glView = cc.Director:getInstance():getOpenGLView()
|
||||
local screenSize = glView:getFrameSize()
|
||||
local designSize = {width = 480, height = 320}
|
||||
local fileUtils = cc.FileUtils:getInstance()
|
||||
|
||||
if screenSize.height > 320 then
|
||||
local searchPaths = {}
|
||||
table.insert(searchPaths, "hd")
|
||||
fileUtils:setSearchPaths(searchPaths)
|
||||
end
|
||||
|
||||
local targetPlatform = cc.Application:getInstance():getTargetPlatform()
|
||||
local resPrefix = ""
|
||||
if cc.PLATFORM_OS_IPAD == targetPlatform or cc.PLATFORM_OS_IPHONE == targetPlatform or cc.PLATFORM_OS_MAC == targetPlatform then
|
||||
resPrefix = ""
|
||||
else
|
||||
resPrefix = "res/"
|
||||
end
|
||||
|
||||
local searchPaths = fileUtils:getSearchPaths()
|
||||
table.insert(searchPaths, 1, resPrefix)
|
||||
table.insert(searchPaths, 1, resPrefix .. "cocosbuilderRes")
|
||||
|
||||
if screenSize.height > 320 then
|
||||
table.insert(searchPaths, 1, resPrefix .. "hd")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/Images")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ArmatureComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/AttributeComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/BackgroundComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/EffectComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/LoadSceneEdtiorFileTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/ParticleComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/SpriteComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TmxMapComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/UIComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/hd/scenetest/TriggerTest")
|
||||
else
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/Images")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ArmatureComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/AttributeComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/BackgroundComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/EffectComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/LoadSceneEdtiorFileTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/ParticleComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/SpriteComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TmxMapComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/UIComponentTest")
|
||||
table.insert(searchPaths, 1, resPrefix .. "ccs-res/scenetest/TriggerTest")
|
||||
end
|
||||
|
||||
fileUtils:setSearchPaths(searchPaths)
|
||||
|
||||
local scene = cc.Scene:create()
|
||||
scene:addChild(CreateTestMenu())
|
||||
cc.Director:getInstance():runWithScene(scene)
|
||||
if cc.Director:getInstance():getRunningScene() then
|
||||
cc.Director:getInstance():replaceScene(scene)
|
||||
else
|
||||
cc.Director:getInstance():runWithScene(scene)
|
||||
end
|
||||
|
|
|
@ -1 +1 @@
|
|||
Subproject commit edd24a1dcc0d8344038e4d46367c603b2a846ab5
|
||||
Subproject commit 29cfa00a4b85f934eefe0b2fae460bd9a55ee345
|
|
@ -190,16 +190,13 @@ def main():
|
|||
data = re.sub('<uses-feature android:glEsVersion="0x00020000" />', '<uses-feature android:glEsVersion="0x00020000" /> <uses-permission android:name="android.permission.INTERNET"/>', data)
|
||||
codecs.open(modify_file, 'wb', encoding='UTF-8').write(data)
|
||||
print "Start build android..."
|
||||
ret = os.system("python build/android-build.py -n -j10 all")
|
||||
ret = os.system("python build/android-build.py -p 10 all")
|
||||
# create and save apk
|
||||
if(ret == 0):
|
||||
sample_dir = 'tests/cpp-empty-test/proj.android/'
|
||||
os.system('android update project -p cocos/platform/android/java/ -t android-13')
|
||||
os.system('android update project -p ' + sample_dir + ' -t android-13')
|
||||
os.system('ant debug -f ' + sample_dir + 'build.xml')
|
||||
local_apk = sample_dir + 'bin/CppEmptyTest-debug.apk'
|
||||
remote_apk = 'apks/cpp_empty_test/cpp_empty_test_' + str(pr_num) + '.apk'
|
||||
os.system('tools/jenkins-scripts/upload_apk.sh ' + local_apk + ' ' + remote_apk)
|
||||
sample_dir = 'tests/cpp-tests/proj.android/'
|
||||
local_apk = sample_dir + 'bin/CppTests-debug.apk'
|
||||
backup_apk = os.environ['BACKUP_PATH'] + 'CppTests_' + str(pr_num) + '.apk'
|
||||
os.system('cp ' + local_apk + ' ' + backup_apk)
|
||||
elif(node_name == 'win32_win7'):
|
||||
ret = subprocess.call('"%VS110COMNTOOLS%..\IDE\devenv.com" "build\cocos2d-win32.vc2012.sln" /Build "Debug|Win32"', shell=True)
|
||||
elif(node_name == 'ios_mac'):
|
||||
|
|
|
@ -101,8 +101,8 @@ skip = Node::[setGLServerState description getUserObject .*UserData getGLServerS
|
|||
Scheduler::[pause resume unschedule schedule update isTargetPaused isScheduled performFunctionInCocosThread],
|
||||
TextureCache::[addPVRTCImage addImageAsync],
|
||||
Timer::[getSelector createWithScriptHandler],
|
||||
*::[^visit$ copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate onTouch.* onAcc.* onKey.* onRegisterTouchListener],
|
||||
FileUtils::[(g|s)etSearchResolutionsOrder$ (g|s)etSearchPaths$ getFileData getDataFromFile getFullPathCache],
|
||||
*::[copyWith.* onEnter.* onExit.* ^description$ getObjectType (g|s)etDelegate onTouch.* onAcc.* onKey.* onRegisterTouchListener],
|
||||
FileUtils::[getFileData getDataFromFile getFullPathCache],
|
||||
Application::[^application.* ^run$],
|
||||
Camera::[getEyeXYZ getCenterXYZ getUpXYZ],
|
||||
ccFontDefinition::[*],
|
||||
|
|
Loading…
Reference in New Issue