This article says, ProgressTimer preserved it's behavior while migration to Cocos Creator:
http://cocos2d-x.org/docs/editors_and_tools/creator-chapters/getting-started/cocos2d-x-guide/2
So, I tried to create ProgressTimer from code with both:
var obj1 = new cc.ProgressTimer(sprite); // -> cc.ProgressTimer is not a constructor
and
var obj2 = cc.ProgressTimer.create(sprite); // -> Cannot read property 'create' of undefined
code lines and as you see nothing is working for me.
I'm using Cocos Creator 1.4.
I can't even find CCProgressTimer.js inside CocosCreator directory.
Also, I can't find CCClippingNode.js(which is also listed in preserved nodes list on Cocos Creator docs). But there is still CCSprite.js file presented. What am I missed up?
You can use the Progress Bar and do the timer yourself. Also you should read the API for the version of Cocos Creator that you are using. Many things change from version to version.
http://www.cocos2d-x.org/docs/api-ref/creator/v1.5/classes/ProgressBar.html
Related
I have an application that adds many custom meshes to the Forge Viewer using the ModelBuilder extension. This application has worked for quite a while but ran into issues with version 7.71 of the viewer.
When graphics are updated in my application, I remove all existing meshes and then recreate them based on new data. With version 7.71 of the viewer, when I recreate the meshes I get many instances the following error in the dev tools console:
Uncaught TypeError: Cannot read properties of undefined (reading 'material')
at FragmentList.getMaterial (FragmentList.js:760:1)
at FragmentList.getMaterialId (FragmentList.js:754:1)
at RenderBatch.js:222:1
at Int32Array.sort (<anonymous>)
at RenderBatch.sortByMaterial (RenderBatch.js:220:1)
at RenderModel.applyVisibility (RenderModel.js:388:1)
at RenderModel.nextBatch (RenderModel.js:360:1)
at RenderScene.reset (RenderScene.js:387:1)
at Array.cmdBeginPhase (Viewer3DImpl.js:1125:1)
at RenderCommandSystem.executeCommandList (Viewer3DImpl.js:847:1)
After these errors, the new meshes are not created.
The release notes don't mention anything about any expected changes here. Looking for guidance from the Autodesk team.
Here is a repo that reproduces the issue:
https://github.com/bencameron/custom-mesh-refresh
I'm told it will take some time to implement the fix (ticket id LMV-6757). In the meantime you could stick with v7.70 or try these workarounds a colleague suggested:
1.) If all of the custom geometry is removed, like it is in the example app, it's probably simpler to remove the model entirely and start with a new one. Here is an (untested) snippet to do that:
// Instead of deleting all geometries individually, simply delete the model and create a new one
viewer.unloadModel(modelBuilder.model);
// drop the reference to the model builder instance, i.e. assign a new instance
modelBuilder = await sceneBuilder.addNewModel({});
// start adding the geometry again...
...
2.) If option #1 doesn't work, or if the user doesn't want to delete all geometries, they could also avoid the crash by running this snippet right after adding new geometries (i.e. every time they add a batch of geometries):
const scenes = modelBuilder.model.getIterator().getGeomScenes();
for (let i = 0; i < scenes.length; ++i) {
scenes[i].numAdded = 0;
}
I would recommend the first option over the second one if applicable.
I have created a new solution for my MvvmCross app that supported Windows Store and I want to support UWP on Windows 10. I have moved over the PCL successfully, but I am having problems getting the basic UWP app working using a sample provided by MS (NavigationMenu) which uses the SplitView and the AppShell pattern they are recommending for the new navigation/command model. I referenced a helpful blog post (http://stephanvs.com/implementing-a-multi-region-presenter-for-windows-10-uwp-and-mvvmcross/), which gave me some guidance on how to integrate mvvmcross into the AppShell, but startup is failing because the AppShell does not have a valid Frame defined. Frame is a read-only property, and I have been unable to see where this is being set up.
I am using the standard AppShell implementation from the NavigationMenu with the following changes as recommended in the blog post:
public sealed partial class AppShell : MvxWindowsPage // was Page
public Frame AppFrame { get { return this.Frame; } } // was this.frame
Except for code after the error, there are no differences in the setup. In looking at the MvxWindowsPage implementation, there doesn't seem to be anything special as it still invokes the Page initialization. Is there something obvious I am missing?
So the link to the blogpost is correct, in other words you'll need to use MultiRegions from MvvmCross to get this working.
But what the blogpost doesn't show is a complete working version...
I've added one on my github here:
https://github.com/Depechie/MvvmCrossUWPSplitView
Some pointers to take away, like I said in the comments.
Your view where the SplitView will be present, needs to have a property to return a valid Frame to look for while injecting new views. This can be returned like this return (Frame)this.WrappedFrame.UnderlyingControl; found in the code here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/FirstView.xaml.cs#L13
Than all views you want to load up in the SplitView will need to reference to the region you defined in that SplitView, in my case I named it FrameContent as seen here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/FirstView.xaml#L48
So use that name for the region attribute in all to be loaded views like so [MvxRegion("FrameContent")] example here https://github.com/Depechie/MvvmCrossUWPSplitView/blob/master/MvvmCrossUWP.Win/Views/SecondView.xaml.cs#L7
I see what you're trying to do with the SplitView template that's provided by Microsoft. There is however a mismatch between things managed by MvvmCross and UWP.
By default MvvmCross maps ViewModels to Views based on naming conventions. What you are trying to do is use a view 'AppShell' (which is derived of Windows.UI.Xaml.Controls.Page) that doesn't adhere to the default MvvmCross convention.
The way I choose to implement this SplitView (Hamburger) functionality is by deleting the provided AppShell class entirely. I then created a new view named HomeView (since I have a ViewModel with the name HomeViewModel) and added the SplitView control there as described in the post you mentioned above.
For completeness I've created a Gist with the App.xaml.cs and HomeView.xaml as you requested. You can find them here: https://gist.github.com/Stephanvs/7bb2cdc9dbf15cb7a90f
I'm trying to learn from a sample source code (Since the framework is utterly undocumented) that was written for cocos2d-x 3.0alpha, the code is using the deprecated class "Object", I'm trying to port the code to version 3.0 but I'm not sure which class be used instead of Object.
Do you have any idea?
https://github.com/OiteBoys/Earlybird/blob/master/Earlybird/Classes/Number.h
Edit: pretty sure the class I need is Ref
Current issue I'm trying to solve is finding the equivalent of EGLView::getInstance()
Edit II: GLView::create("view"); seems to be it.
Yes, you need Ref. Here are the release notes for Version 3.0. It describes this here. This changes was done since C++ doesn't have and doesn't need a base object. Object was created for that reason originally but now deprecated.
https://github.com/cocos2d/cocos2d-x/blob/v3/docs/RELEASE_NOTES.md
For EGLView create a quick sample "Hello World" project using the cocos command-line tool and have a look at AppController.mm, RootViewController.mm and AppDelegate.cpp. These have changed a good deal for version 3.0+.
Edit: based upon your edit look at: bool AppDelegate::applicationDidFinishLaunching()
// initialize director
auto director = Director::getInstance();
auto glview = director->getOpenGLView();
if(!glview) {
glview = GLView::create("My Game");
director->setOpenGLView(glview);
}
I recently found Mike Chambers' as3corelib when looking for ways to render the stage to a file. Works great in my ActionScript 3.0 project in Flash Professional (CS6 if it matters).
I decided to look at some of Mike's utility classes, notably the date related ones. However, his DateUtil class imports mx.formatters.DateBase, and when I attempt to use some of the methods, I'm getting lots (and lots) of "Access of undefined property DateBase."
I'm assuming that's because some reference to the Flex SDK is missing or wrong. I've added $(FlexSDK)/frameworks/libs/flex.swc to my project's Library path, but that's not helping.
I've used Flash for years, but this is my first truly code-centric project, and still learning through the school of hard knocks. No idea what's going wrong here. Ideas?
Example from as3corelib
package com.adobe.utils
{
import mx.formatters.DateBase;
/**
* Class that contains static utility methods for manipulating and working
* with Dates.
*/
public class DateUtil
{
/**
* Returns a date string formatted according to RFC822.
*/
public static function toRFC822(d:Date):String
{
var date:Number = d.getUTCDate();
var hours:Number = d.getUTCHours();
var minutes:Number = d.getUTCMinutes();
var seconds:Number = d.getUTCSeconds();
var sb:String = new String();
sb += DateBase.dayNamesShort[d.getUTCDay()];
sb += ", ";
...
The line:
sb += DateBase.dayNamesShort[d.getUTCDay()];
...generates the mentioned error, as does any other DateBase reference in the class. Again, this code is directly from the latest as3corelib, located on GitHub: https://github.com/mikechambers/as3corelib
Don't know whether you got this one licked or not, but I hit the same thing. Love the library, hate the error messages.
I downloaded the Flex SDK from here:
Adobe Flex SDK Download
Then, I unzipped that into a temporary folder.
Then, since I didn't want the whole flex framework lurking about, I created a ./lib directory inside the directory where the .fla file lives. I then moved these swcs from here (Inside the unzipped file structure):
mv ~/Downloads/flex_sdk_4.6/frameworks/libs/framework.swc ./lib
mv ~/Downloads/flex_sdk_4.6/frameworks/libs/core.swc ./lib
mv ~/Downloads/flex_sdk_4.6/frameworks/libs/mx/mx.swc ./lib
Not sure why all three were required, but it stopped the compiler complaining (and got the date conversions working).
You need to add them to the .fla's library list as well (under ActionScript Settings); but I'm betting you already knew that.
Perhaps useful, perhaps not.
1. Compiled Assembly from JSC
I've compiled what is intended to be client-side JavaScript using the JScript compiler (jsc.exe) on the server side in an attempt to make something that can be tested from a unit testing project, and maybe even something that can be debugged on the server side.
The compiled file contains only functions as follows (just for example) and it compiles fine into BitField.exe. Notice, no wrapper class or package in the source code.
------ BEGIN FILE (BitField.js) -------
function BitField(){
this.values = [];
}
// more functions ...
------- END FILE -------
jsc /fast- /out:BitField.exe Bitfield.js
Results in a BitField.exe assembly.
Success! Well, kind of ....
2. Testing Assembly / Access Point?
Secondly I've created a test project (in C#) and referenced in the BitField.exe assembly successfully. (The type of project is irrelevant but I'm providing more description to paint a full picture.)
The problem seems to be: I cannot find the namespace or a point at which I can access the BitField functions inside the BitField.exe assembly from my C# test project. The assembly doesn't seem to be a "normal".
In other words I need in C#
using ???WHAT???
Note: I don't want to use JScript "extensions", meaning keywords that won't run client-side (in a web browser), for example, class, package etc because I want the code to be clean as possible for copy & paste back into client side script environment (Regardless said "clean" code compiles fine by jsc.exe without use of those extensions). When I try to wrap the functions in package and class it starts producing compile errors so that's another reason not to use them - because they appear to make me alter my code.
Any suggestions as to how I can use the functions of the compiled JScript assembly (by having it referenced into another assembly) when there are no explicit containers in it?
Update / Proof
.NET Reflector view
After playing around with it for a while, and trying various combinations of command-line switches for jsc.exe, I'm pretty sure that what you're trying to do won't work as you'd wish it to. If you try to compile a js file that contains functions into a .Net library assembly, you get an error:
BitField.js(1,1) : error JS1234: Only type and package definitions are allowed inside a library
But, there is hope, yet! Here's what I would do...
I would keep your "clean" BitField.js file just as it is, and then create a batch file that wraps it in a JScript class and writes it out to a "dirty" js file. It's pretty clean if you think of it as part of the compilation of the code into the DLL. The code to wrap the BitField.js into BitFieldClass.js would look like this:
merge-into-class.js
var fso = new ActiveXObject("Scripting.FileSystemObject");
var ForReading = 1;
var inputFile = fso.OpenTextFile("BitField.js",ForReading, false);
var outputFile = fso.CreateTextFile("BitFieldClass.js", true);
outputFile.write("class BitFieldClass{\n");
while (!inputFile.AtEndOfStream)
{
var textLine = inputFile.ReadLine();
outputFile.write (textLine + "\n");
}
outputFile.write("}");
outputFile.close();
Then the batch file to wrap it and compile it is really simple:
compile-js.bat
cscript merge-into-class.js
jsc /t:library /out:BitFieldClass.dll bitFieldClass.js
Of course, if you wanted to do multiple files, you'd have to parameterize things a bit, but hopefully this is enough to demonstrate the idea.