mirror of
https://github.com/4ian/GDevelop.git
synced 2025-10-15 10:19:04 +00:00
Added example for Js code event.
This commit is contained in:
@@ -0,0 +1,186 @@
|
||||
<?xml version="1.0" encoding="ISO-8859-1" ?>
|
||||
<project firstLayout="">
|
||||
<gdVersion build="75" major="3" minor="5" revision="0" />
|
||||
<properties linuxExecutableFilename="" macExecutableFilename="" useExternalSourceFiles="false" winExecutableFilename="" winExecutableIconFile="">
|
||||
<name>Project</name>
|
||||
<author></author>
|
||||
<windowWidth>800</windowWidth>
|
||||
<windowHeight>600</windowHeight>
|
||||
<latestCompilationDirectory></latestCompilationDirectory>
|
||||
<maxFPS>60</maxFPS>
|
||||
<minFPS>10</minFPS>
|
||||
<verticalSync>false</verticalSync>
|
||||
<extensions>
|
||||
<extension name="BuiltinObject" />
|
||||
<extension name="BuiltinAudio" />
|
||||
<extension name="BuiltinVariables" />
|
||||
<extension name="BuiltinTime" />
|
||||
<extension name="BuiltinMouse" />
|
||||
<extension name="BuiltinKeyboard" />
|
||||
<extension name="BuiltinJoystick" />
|
||||
<extension name="BuiltinCamera" />
|
||||
<extension name="BuiltinWindow" />
|
||||
<extension name="BuiltinFile" />
|
||||
<extension name="BuiltinNetwork" />
|
||||
<extension name="BuiltinScene" />
|
||||
<extension name="BuiltinAdvanced" />
|
||||
<extension name="Sprite" />
|
||||
<extension name="BuiltinCommonInstructions" />
|
||||
<extension name="BuiltinCommonConversions" />
|
||||
<extension name="BuiltinStringInstructions" />
|
||||
<extension name="BuiltinMathematicalTools" />
|
||||
<extension name="BuiltinExternalLayouts" />
|
||||
</extensions>
|
||||
<platforms>
|
||||
<platform name="GDevelop JS platform" />
|
||||
</platforms>
|
||||
<currentPlatform>GDevelop JS platform</currentPlatform>
|
||||
</properties>
|
||||
<resources>
|
||||
<resources>
|
||||
<resource alwaysLoaded="false" file="Pea-Standard.png" kind="image" name="Pea-Standard.png" smoothed="true" userAdded="true" />
|
||||
</resources>
|
||||
<resourceFolders />
|
||||
</resources>
|
||||
<objects />
|
||||
<objectsGroups />
|
||||
<variables />
|
||||
<layouts>
|
||||
<layout b="209" disableInputWhenNotFocused="true" mangledName="New_32scene" name="New scene" oglFOV="90.000000" oglZFar="500.000000" oglZNear="1.000000" r="209" standardSortMethod="true" stopSoundsOnStartup="true" title="" v="209">
|
||||
<uiSettings associatedLayout="" grid="false" gridB="255" gridG="180" gridHeight="32" gridOffsetX="0" gridOffsetY="0" gridR="158" gridWidth="32" snap="true" windowMask="false" zoomFactor="1.000000" />
|
||||
<objectsGroups />
|
||||
<variables />
|
||||
<instances>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="411.999969" y="203.500031" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="90.000000" y="97.500015" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="468.000000" y="303.500000" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="572.000000" y="97.500015" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="147.000000" y="300.500031" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="315.000000" y="140.500031" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="200.999985" y="205.500031" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
<instance angle="0.000000" customSize="false" height="0.000000" layer="" locked="false" name="Pea" width="0.000000" x="417.000031" y="65.500015" zOrder="1">
|
||||
<numberProperties />
|
||||
<stringProperties />
|
||||
<initialVariables />
|
||||
</instance>
|
||||
</instances>
|
||||
<objects>
|
||||
<object name="Pea" type="Sprite">
|
||||
<variables />
|
||||
<automatisms />
|
||||
<animations>
|
||||
<animation useMultipleDirections="false">
|
||||
<directions>
|
||||
<direction looping="false" timeBetweenFrames="1.000000">
|
||||
<sprites>
|
||||
<sprite hasCustomCollisionMask="false" image="Pea-Standard.png">
|
||||
<points />
|
||||
<originPoint name="origine" x="0.000000" y="0.000000" />
|
||||
<centerPoint automatic="true" name="centre" x="18.500000" y="18.500000" />
|
||||
<customCollisionMask>
|
||||
<polygon>
|
||||
<vertice x="0.000000" y="0.000000" />
|
||||
<vertice x="37.000000" y="0.000000" />
|
||||
<vertice x="37.000000" y="37.000000" />
|
||||
<vertice x="0.000000" y="37.000000" />
|
||||
</polygon>
|
||||
</customCollisionMask>
|
||||
</sprite>
|
||||
</sprites>
|
||||
</direction>
|
||||
</directions>
|
||||
</animation>
|
||||
</animations>
|
||||
</object>
|
||||
</objects>
|
||||
<events>
|
||||
<event disabled="false" folded="false">
|
||||
<type>BuiltinCommonInstructions::Comment</type>
|
||||
<color b="109" g="230" r="255" textB="0" textG="0" textR="0" />
|
||||
<comment>Custom javascript code can access to the specified objects and to the scene:</comment>
|
||||
<comment2></comment2>
|
||||
</event>
|
||||
<event disabled="false" folded="false">
|
||||
<type>BuiltinCommonInstructions::JsCode</type>
|
||||
<inlineCode>for(var i = 0;i<objects.length;++i) {
	objects[i].setAngle(Math.cos(runtimeScene.getTimeFromStart()/100)*90);
}</inlineCode>
|
||||
<parameterObjects>Pea</parameterObjects>
|
||||
</event>
|
||||
<event disabled="false" folded="false">
|
||||
<type>BuiltinCommonInstructions::Comment</type>
|
||||
<color b="109" g="230" r="255" textB="0" textG="0" textR="0" />
|
||||
<comment>Of course, objects are picked as in any other event: here, a window is displaying the coordinates of the pea that was clicked.</comment>
|
||||
<comment2></comment2>
|
||||
</event>
|
||||
<event disabled="false" folded="false">
|
||||
<type>BuiltinCommonInstructions::Standard</type>
|
||||
<conditions>
|
||||
<condition>
|
||||
<type inverted="false" value="SourisSurObjet" />
|
||||
<parameters>
|
||||
<parameter>Pea</parameter>
|
||||
<parameter></parameter>
|
||||
<parameter></parameter>
|
||||
</parameters>
|
||||
<subConditions />
|
||||
</condition>
|
||||
<condition>
|
||||
<type inverted="false" value="SourisBouton" />
|
||||
<parameters>
|
||||
<parameter></parameter>
|
||||
<parameter>Left</parameter>
|
||||
</parameters>
|
||||
<subConditions />
|
||||
</condition>
|
||||
</conditions>
|
||||
<actions />
|
||||
<events>
|
||||
<event disabled="false" folded="false">
|
||||
<type>BuiltinCommonInstructions::JsCode</type>
|
||||
<inlineCode>var pea = objects[0];
if (!pea) {
	return;
}
window.alert("You clicked on Pea at position "+
	pea.getX()+";"+pea.getY()+" !");</inlineCode>
|
||||
<parameterObjects>Pea</parameterObjects>
|
||||
</event>
|
||||
</events>
|
||||
</event>
|
||||
</events>
|
||||
<layers>
|
||||
<layer name="" visibility="true">
|
||||
<cameras>
|
||||
<camera defaultSize="true" defaultViewport="true" height="0.000000" viewportBottom="1.000000" viewportLeft="0.000000" viewportRight="1.000000" viewportTop="0.000000" width="0.000000" />
|
||||
</cameras>
|
||||
</layer>
|
||||
</layers>
|
||||
<automatismsSharedData />
|
||||
</layout>
|
||||
</layouts>
|
||||
<externalEvents />
|
||||
<externalLayouts />
|
||||
<externalSourceFiles />
|
||||
</project>
|
@@ -4,12 +4,34 @@
|
||||
#include "GDCore/IDE/Dialogs/ChooseObjectDialog.h"
|
||||
#include "GDJS/JsCodeEvent.h"
|
||||
|
||||
enum
|
||||
{
|
||||
MARGIN_LINE_NUMBERS,
|
||||
MARGIN_FOLD
|
||||
};
|
||||
|
||||
JsCodeEventDialog::JsCodeEventDialog(wxWindow* parent, gdjs::JsCodeEvent & event_, gd::Project & project_, gd::Layout & layout_)
|
||||
: BaseJsCodeEventDialog(parent),
|
||||
event(event_),
|
||||
project(project_),
|
||||
layout(layout_)
|
||||
{
|
||||
//Customize the code editor
|
||||
codeEdit->SetLexer(wxSTC_LEX_ESCRIPT);
|
||||
#if defined(WINDOWS)
|
||||
wxFont font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL, false, "Consolas");
|
||||
#else
|
||||
wxFont font(9, wxFONTFAMILY_TELETYPE, wxFONTSTYLE_NORMAL, wxFONTWEIGHT_NORMAL);
|
||||
#endif
|
||||
|
||||
codeEdit->StyleSetFont(wxSTC_STYLE_DEFAULT, font);
|
||||
codeEdit->StyleSetBackground(34, wxColour(119, 255, 119)); //Brace
|
||||
codeEdit->StyleSetBackground(35, wxColour(255, 119, 119)); //Brace
|
||||
codeEdit->SetMarginWidth (MARGIN_LINE_NUMBERS, 20);
|
||||
codeEdit->StyleSetForeground (wxSTC_STYLE_LINENUMBER, wxColour (75, 75, 75) );
|
||||
codeEdit->StyleSetBackground (wxSTC_STYLE_LINENUMBER, wxColour (220, 220, 220));
|
||||
codeEdit->SetMarginType (MARGIN_LINE_NUMBERS, wxSTC_MARGIN_NUMBER);
|
||||
|
||||
objectsEdit->SetValue(event.GetParameterObjects());
|
||||
codeEdit->SetText(event.GetInlineCode());
|
||||
}
|
||||
|
Reference in New Issue
Block a user