void Torpedo::OnUpdate(float time_diff) { /*if(mLifetime > 0.5) { Speed.y = 0; Speed.x += 200 * time_diff; } else { Speed.y *= (1.f - 0.5 * time_diff); }*/ Speed.x += 200 * time_diff; if(mLifetime > 2) { GetParent()->RemoveChild(this); return; } mSprite.SetPosition(GetAbsolutePosition().x, GetAbsolutePosition().y); mSprite.SetRotation(Vector2D::rad2Deg(GetAbsoluteRotation())); mSprite.SetScale(GetAbsoluteSize().x, GetAbsoluteSize().y); }
//---Touch Delegates //---------------------------------------------------------- //----------------------------------------------------------- void HorizontalSliderBar::OnSliderMoved(GUIView* in_view, const Input::Pointer& in_pointer) { mfSliderValue = ((in_pointer.GetPosition().x - GetAbsoluteScreenSpacePosition().x)/GetAbsoluteSize().x) + 0.5f; mpSliderImage->SetPosition(mfSliderValue, 0.5f, 0.0f, 0.0f); }
void Rock::OnUpdate(float time_diff) { mSprite.SetPosition(GetAbsolutePosition().x, GetAbsolutePosition().y); mSprite.SetRotation(Vector2D::rad2Deg(GetAbsoluteRotation())); mSprite.SetScale(GetAbsoluteSize().x, GetAbsoluteSize().y); }
//------------------------------------------------------- /// Draw /// /// Draw the text using the canvas then draw any /// subviews /// /// @param Canvas renderer //------------------------------------------------------- void EditableLabel::Draw(Rendering::CanvasRenderer* inpCanvas) { CS_ASSERT(Font != nullptr, "Cannot draw editable label without a font."); //Check if this is on screen Core::Vector2 vTopRight = GetAbsoluteScreenSpaceAnchorPoint(Rendering::AlignmentAnchor::k_topRight); Core::Vector2 vBottomLeft = GetAbsoluteScreenSpaceAnchorPoint(Rendering::AlignmentAnchor::k_bottomLeft); if(vTopRight.y < 0 || vBottomLeft.y > GetScreen()->GetResolution().y || vTopRight.x < 0 || vBottomLeft.x > GetScreen()->GetResolution().x) { //Offscreen return; } DoAutosizing(inpCanvas); //Calculate the size of the label box Core::Vector2 vAbsoluteLabelSize = GetAbsoluteSize(); Core::Colour AbsCol = GetAbsoluteColour(); //Check if we force clip our children if(ClipSubviews) { inpCanvas->PushClipBounds(vBottomLeft, vAbsoluteLabelSize); } //Draw ourself if(Background) { inpCanvas->DrawBox(GetTransform(), GetAbsoluteSize(), Core::Vector2::k_zero, mpWhiteTex, Rendering::UVs(0.0f, 0.0f, 1.0f, 1.0f), AbsCol, Rendering::AlignmentAnchor::k_middleCentre); } if(Text.length() > 0) { std::string strutf8DisplayString(Text); if(SecureEntry) { std::string strSecureText; u32 udwTextLength = Core::UTF8StringUtils::CalcLength(strutf8DisplayString.begin(), strutf8DisplayString.end()); for(u32 i=0; i<udwTextLength; ++i) { strSecureText.append("*"); } strutf8DisplayString = strSecureText; } if(mCachedChars.empty()) { f32 fAssetTextScale = GetGlobalTextScale(); mCachedChars = inpCanvas->BuildText(strutf8DisplayString, Font, TextScale * fAssetTextScale, LineSpacing, vAbsoluteLabelSize, MaxNumLines, HorizontalJustification, VerticalJustification).m_characters; } inpCanvas->DrawText(mCachedChars, GetTransform(), TextColour, Font->GetTexture()); } //Draw the kids for(GUIView::Subviews::iterator it = mSubviews.begin(); it != mSubviews.end(); ++it) { (*it)->Draw(inpCanvas); } if(ClipSubviews) { inpCanvas->PopClipBounds(); } }